notes:backups
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| notes:backups [2021/10/02 19:59] – david | notes:backups [2024/08/31 23:29] (current) – [Prep backup server] david | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | How I backup servers locally and in the cloud using rsync, restricted-rsync, | + | How I backup servers locally and in the cloud using rsync, restricted-rsync, |
| + | |||
| + | Android phones have their photos backed up to a central backup server using syncthing, which is then backed up to the cloud using restic. | ||
| + | Servers are backed up using rsync and restricted-rsync | ||
| Tools used | Tools used | ||
| Line 8: | Line 11: | ||
| * [[ https:// | * [[ https:// | ||
| * [[ https:// | * [[ https:// | ||
| - | Setup / | ||
| - | command="/ | ||
| - | |||
| - | This will force the use of rrsync to the / directory as read-only, when logging in using the specified key, from 192.0.2.2 . | ||
| ====== restic ====== | ====== restic ====== | ||
| ====== rsnapshot ====== | ====== rsnapshot ====== | ||
| + | create a new ed25519 key on the backup server, and copy the public | ||
| + | Setup / | ||
| + | command="/ | ||
| + | |||
| + | This will force the use of rrsync to the / directory as read-only, when logging in using the specified key, from 192.0.2.2 . | ||
| + | |||
| + | |||
| + | make sure to use the " | ||
| + | "it can also help keep a copy-on-write | ||
| + | |||
| + | ===== rsnapshot and btrfs ===== | ||
| + | In order to take advantage of btrfs subvolumes with rsnapshot the following options in the rsnapshot configuration will need to be modified according to (( https:// | ||
| + | < | ||
| + | cmd_cp | ||
| + | cmd_rm | ||
| + | </ | ||
| + | |||
| + | snapshot_plug_cp_btrfs ((https:// | ||
| + | <code bash rsnapshot_plug_cp_btrfs> | ||
| + | #!/bin/sh | ||
| + | # Arg 1: -al | ||
| + | # Arg 2: / | ||
| + | # Arg 3: / | ||
| + | btrfs subvolume snapshot $2 $3 | ||
| + | </ | ||
| + | |||
| + | rsnapshot_plug_rm_btrfs | ||
| + | ((https:// | ||
| + | <code bash rsnapshot_plug_rm_btrfs> | ||
| + | #!/bin/sh | ||
| + | |||
| + | # Arg 1: -rf | ||
| + | # Arg 2: / | ||
| + | |||
| + | # echo 1: $1 2: $@ | ||
| + | |||
| + | # Try to delete the given path with btrfs subvolume delete first | ||
| + | # if this fails fall back to normal rm | ||
| + | if [ " | ||
| + | # " | ||
| + | btrfs subvolume delete $2 | ||
| + | error=$? | ||
| + | if [ $error -eq 13 ]; then | ||
| + | # EC 13 => The directory specified is no subvolume | ||
| + | rm $@ | ||
| + | elif [ $error -ne 0 ]; then | ||
| + | echo Error while deleting with btrfs $? | ||
| + | fi | ||
| + | else | ||
| + | rm $@ | ||
| + | fi | ||
| + | </ | ||
| + | https:// | ||
| + | |||
| ====== syncthing ====== | ====== syncthing ====== | ||
| Line 26: | Line 79: | ||
| < | < | ||
| mkdir -p / | mkdir -p / | ||
| - | chown gatewaybackups | + | chown gatewaybackup |
| </ | </ | ||
| Line 39: | Line 92: | ||
| </ | </ | ||
| edit the / | edit the / | ||
| + | |||
| + | update cron to run it nightly | ||
| + | / | ||
| + | < | ||
| + | 54 1 * * * / | ||
| + | </ | ||
| create ssh key to login to backupserver | create ssh key to login to backupserver | ||
| Line 55: | Line 114: | ||
| https:// | https:// | ||
| + | |||
| + | https:// | ||
notes/backups.1633219162.txt.gz · Last modified: by david
