Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Using Timeshift on a headless server with no GUI #150

Open
OrangeReaper opened this issue Mar 7, 2023 · 3 comments
Open

Comments

@OrangeReaper
Copy link

OrangeReaper commented Mar 7, 2023

I believe that it would be an improvement to existing documentation to include an example of using Timeshift on a headless server. After a fair amount of googling and piecing together a methodology (any blogs that I found on the subject were incomplete) which I offer below:

Install timeshift using

$ sudo apt install timeshift -y

After installation we should manually run timeshift and create our first snapshot; first we need to know the details of the filesystem

$ df -h

the response will be something like:

Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              385M  2.0M  383M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   27G   14G   12G  54% /
tmpfs                              1.9G     0  1.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/mmcblk2p2                     1.5G  594M  790M  43% /boot
/dev/mmcblk2p1                     1.1G  6.1M  1.1G   1% /boot/efi
/dev/sda1                          229G   34G  184G  16% /media/usb
tmpfs                              385M  4.0K  385M   1% /run/user/1000

Our target device is /dev/sda1

To create first snapshot run timeshift with the following command:

$ sudo timeshift --create --comments "First Snapshot" --snapshot-device /dev/sda1

Output:

First run mode (config file not found)
Selected default snapshot type: RSYNC
Mounted '/dev/sda1' at '/run/timeshift/backup'
------------------------------------------------------------------------------
Estimating system size...
Creating new snapshot...(RSYNC)
Saving to device: /dev/sda1, mounted at path: /run/timeshift/backup
Synching files with rsync...
Created control file: /run/timeshift/backup/timeshift/snapshots/2023-03-05_09-39-32/info.json
RSYNC Snapshot saved successfully (1179s)
Tagged snapshot '2023-03-05_09-39-32': ondemand
------------------------------------------------------------------------------

After this command the Timeshift configuration files can be found @ /etc/timeshift/timeshift.json; these should be modified according to your needs.

For Example:

{
  "backup_device_uuid" : "00c58084-7b61-4f18-a321-d977b4e0b6cb",
  "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",
  "btrfs_use_qgroup" : "true",
  "schedule_monthly" : "true",
  "schedule_weekly" : "false",
  "schedule_daily" : "true",
  "schedule_hourly" : "false",
  "schedule_boot" : "true",
  "count_monthly" : "2",
  "count_weekly" : "3",
  "count_daily" : "5",
  "count_hourly" : "6",
  "count_boot" : "5",
  "snapshot_size" : "14093054978",
  "snapshot_count" : "293820",
  "date_format" : "%Y-%m-%d %H:%M:%S",
  "exclude" : [
    "/root/**",
    "/home/user/**"
  ],
  "exclude-apps" : []
}

The above settings configure Timeshift to retain 2 Monthly Backups, 5 Boot Backups and 5 Daily Backups

Finally to ensure settings are properly installed in the system do the following:

$ sudo timeshift --check

Response:

/dev/sda1 is mounted at: /run/timeshift/backup, options: rw,relatime

Boot snapshots are enabled
Last boot snapshot not found
Tagged snapshot '2023-03-05_09-39-32': boot
Daily snapshots are enabled
Last daily snapshot not found
Tagged snapshot '2023-03-05_09-39-32': daily
Monthly snapshot are enabled
Last monthly snapshot not found
Tagged snapshot '2023-03-05_09-39-32': monthly
------------------------------------------------------------------------------
Added cron task: /etc/cron.d/timeshift-hourly
Added cron task: /etc/cron.d/timeshift-boot

To show the current state of play, at any time, use the following command

$ sudo timeshift --list

Response:

/dev/sda1 is mounted at: /run/timeshift/backup, options: rw,relatime

Device : /dev/sda1
UUID   : 00c58084-7b61-4f18-a321-d977b4e0b6cb
Path   : /run/timeshift/backup
Mode   : RSYNC
Status : OK
1 snapshots, 198.9 GB free

Num     Name                 Tags     Description     
------------------------------------------------------------------------------
0    >  2023-03-05_09-39-32  O B D M  First Snapshot
@gerardcarbo
Copy link

Great info. In my case (Ubuntu 20) the config file was on /etc/timeshift.json

@andreas-thoren
Copy link

Great guide. Thanks! One question in your case did sudo timeshift --check set up the chron jobs automatically. In my case that does not seem to be the case. Would you mind sharing how the entries are set up in chron so I can add them manually?

@OrangeReaper
Copy link
Author

Great guide. Thanks! One question in your case did sudo timeshift --check set up the chron jobs automatically. In my case that does not seem to be the case. Would you mind sharing how the entries are set up in chron so I can add them manually?

I understand that sudo timeshift --check sets up the cron jobs automatically (the response says it does)... If I type it again I don't get told that the cron jobs have been added. You can check they are running properly with the command 'sudo timeshift --list'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants