Giocoso 3 - The Database Management Menu : Backup a database

Keep in mind that most of a Giocoso music database, by design, can always be reconstructed from scratch by doing a Full Scan (Option 3): so long as your music files are safe on disk somewhere, you can always get Giocoso to have a fresh look at them and thereby re-create the RECORDINGS table.

But there's the rub: a Giocoso music database is more than just the RECORDINGS table: it's also the PLAYS table, storing the history of everything you've ever played with Giocoso... and that definitely can't be reconstructed, should it ever be lost or corrupted for some reason. Protecting your history of plays is thus a rather important thing to do on a fairly regular basis. The Database Management menu Option 6 has accordingly been provided to make taking a backup of your music database, including its previous play history cargo, as painless as possible.

First, you need to say where you want your backups saved to: take the Administration menu Option 3 to edit the configuration file. Once you've selected the database you want to work with, you'll see this:

The 'Folder where to write database backups' value is a full path to the location where you want backups stored: in the case above, I'm proposing to store things in my home folder, /home/hjr. The default folder is /tmp, but you can set the path to be anything you like, provided only that it exists and you've got permissions to write there. If you were to specify a folder that doesn't exist, for example, then the value is automatically replaced with /tmp anyway.

Once the backup folder has been configured in the Persistent Configuration file in this way, you can simply take the Database Management menu Option 6 to create a fresh backup:

You have first to specify which database you want backed up: you can only backup a single database at a time, no matter how many others might exist. Just up- and down-arrow through the list until the right database is highlighted, then press the Space Bar to select that entry. An asterisk will appear in the brackets next to the database name. Press [Enter] to submit the selection when ready: nn practically no time at all, you'll see this message appear:

Press [OK] to dismiss that message and you'll be returned to the main menu. But what exactly has been produced by this process and where is it?! Well, it's time to break out your PC's file manager:

Here, you see my /home/hjr folder: and the latest entry in it is a file called 'main_Classical_database...something or other'. If you compare that with the name of the database I selected to backup about three screenshots back, you'll be able to work out that the backup file created by Option 6 starts with the name of the database being backed up. The word -backup- is there, too, so that you know, er, that it's a backup of the database! Finally, a time-and-datestamp is appended to the end of the file name (so, you can tell my backup was taken at 10:03 in the morning on 6th November 2023), along with a .tar file extension.

The tar extension tells you that this backup is created as a 'tape archive' -that is, as an uncompressed bundle of folders and files, wrapped up into a single output file. On most Linux distros, you can right-click a tar file and say 'open in Ark' or some equivalent 'archive extractor' tool. If I do that now and click to open all the nested folders included in the tar, you'd see this:

You can see the entire file structure, right down to the .local/share/giocoso3/db from which the data for this backup was sourced. However the db folder inside the tar file only contains the .db file for the selected database (and any related files, such as the .db-wal and .db-shm files needed to make the Giocoso database work properly).

Recovery from this backup would therefore consist of grabbing those three files out of the tar file and copying them manually into the 'real' $HOME/.local/share/giocoso3/db folder, over-writing anything sharing the same file names.

Since backups are so important to do, Giocoso provides one of its few remaining runtime switches to create them on a scheduled basis, without manual interaction. The relevant command is simply:

giocoso3.sh --backup

...which will backup the default database as mentioned in the Persistent Configuration file only. Backing up non-default databases is only possible using the Database Management menu Option 6. As an example, here's how I backup my primary music database on a nightly basis, using the crontab on my music PC:

# Backup the Giocoso Database every night at 2am
# ----------------------------------------------------------------
0 2 * * *      /usr/bin/giocoso3.sh --backup

Bear in mind, however, that the Giocoso database is only a file on a file system: you can perfectly well use standard file system tools to take backup copies of it at any time, without needing to use any of Giocoso's built-in backup capabilities. Here, for example, is another crontab entry I use to create remote backups of all my Giocoso databases in one hit:

# Backup the Giocoso Database every Tuesday at 6pm
# ----------------------------------------------------------------
0 18 * * TUE     /usr/bin/rsync -avh --delete $HOME/.local/share/giocoso3/db/ hjr@remote_server:/home/hjr/Documents/GiocosoBackups

...which simply copies everything sitting in my Giocoso /db subfolder into a single folder on a remote server. The backup gets over-written every week by the newest backup, but that's OK for my purposes. Simple use of 'cp' and 'mv' could achieve similar results. The main point to make here is not that it necessarily matters how you backup your music database... but that you should back it up! Your music play history is at risk if you don't.


[ User Manual Home ] | [ Back to Database Management Menu ]