Timeshift is a well known software to run a back-up of a running system via snapshots.
On a normal desktop machines the program has a very nice and functional GUI for both set-up and restore process.
For headless systems the configuration needs to be performed via CLI, but this is really easy. Similarly, it is possible to revert to a previous snapshot via CLI or using a live distro (e.g. Systemrescue) in case the main system is no longer functional.
1) First thing we need to install timeshift. From terminal run
next we need to write the configuration file
copy, paste and edit the following text in the configuration file:
{
"backup_device_uuid" : "UUID of the disk that will contain the backup files",
"parent_device_uuid" : "",
"do_first_run" : "false",
"btrfs_mode" : "false",
"include_btrfs_home_for_backup" : "false",
"include_btrfs_home_for_restore" : "false",
"stop_cron_emails" : "true",
"schedule_monthly" : "false",
"schedule_weekly" : "true",
"schedule_daily" : "false",
"schedule_hourly" : "false",
"schedule_boot" : "false",
"count_monthly" : "2",
"count_weekly" : "3",
"count_daily" : "5",
"count_hourly" : "2",
"count_boot" : "5",
"date_format" : "%Y-%m-%d %H:%M:%S",
"exclude" : [
"/home/USERNAME/**",
"+ /srv/salt/***",
"+ /srv/pillar/***",
"/srv/**",
"/root/**"
],
"exclude-apps" : []
}
Alles anzeigen
the content of the file is self explanatory and it stores the parameters that are filled in during the set-up process via GUI on a desktop machine.
pay attention to the following:
- enter the UUID of the disk that will save the backup files (not the main disk). Saving the files in a disk that is not the main system is highly recommended
- in the exclude section add the home directory of each user in the system
- the include/exclude syntax requires you to add first the directories to include and then the directories to exclude, in this order, see my example with the /srv directory . The other way round fails on my system
- look up the difference between *, ** and ***
Once all this is taken care of, run the following command to make the first snapshot
the command will create the first snapshot and it will create a new cron job /etc/cron.d/timeshift-hourly
every hour the system runs the check command it will create snapshots based on the json file settings (i.e. create the new snapshot if needed, delete old snapshots, apply relevant tags etc.)
that's it!
to restore the system to a previous snapshot run
and the system will interactively guide you during the task. Alternatively fire up Systemrescue, timeshift is included in the base packages.
as usual:
is your best friend.
Enjoy!
FT