rsync based back up to the local HDD
Disk backup for NFS region on k1nfs and k1boot is taken by borg system. Though it's robust, it takes a time to restore disks from backup data. On the other hand, disk trouble on k1boot induces a system down of whole digital system. So simple backup is useful to recover from disk trouble with shorter down time and is being run in parallel with borg back up system.
Basic idea of implementation
- full backup
$ sudo rsync -av --delete --exclude lost+found /opt/ /mnt/backup/ | tee full-$(date +'%Y%m%d').txt
This is just a complete copy of /opt to /mnt/backup. Deleted files in /opt are also removed from /mnt/backup. So it doesn't basically support to restore files which are accidentally removed by wrong human operation. Depending on the cadence of executing this command, recent deleted files may be able to be restored. /opt and /mnt/backup are assumed to locate different HDD and switching mount point realizes quick recovering from the broken disk trouble of /opt. "--exclude lost+found" is required when disk is formatted as ext3, 4, etc. If xfs or modern journal, it's unnecessary.
- differential backup
$ sudo rsync -av --delete --exclude lost+found --link-dest=/mnt/diff_backup/opt-$(date --date='N days ago' +"%Y%m%d")/ /opt/ /mnt/diff_backup/opt-$(date +'%Y%m%d')/ | tee diff-$(date +'%Y%m%d').txt
This is a differential copy of /opt but copied directories work as a complete copy of /opt at the time of executing rsync process because unchanged files are also in the copied directories as a hard link to files in the previous backup which is designated by the "--link-dest" option. As same as the full backup case, /opt and /mnt/diff_backup are assumed to locate different HDD. On the other hand, all copied directories in every time must be in the same HDD in order to use a hard link. In other words, /mnt/diff_backup containing multiple backups must be a mount point for one HDD. As usual, this restriction is not serious because required disk space is not so different from one for original /opt thanks to the hard link.
Actual operation
For easy execution of full and differential backup, an interface script is prepared as k1boot:/home/controls/work/backup.sh. It's usage as follows.
$ /home/controls/work/backup.sh usage: /home/controls/work/backup.sh full /home/controls/work/backup.sh diff [yyyymmdd]In the case of the differential backup, the reference directory to make a hard link can be designated as the 2nd argument of this script. If it's not designated, "1 day before" (date --date='1 days ago' +"%Y%m%d") is used as default. Scheduled execution of this script is served by crontab. Normally, it can be done on k1boot but k1boot as the old Gentoo system doesn't have crontab. For this reason, crontab@k1script0 currently kicks this script via SSH command execution. This operation will become unnecessary after migrating k1boot to the Debian system as a part of digital system upgrade and k1boot can kick this script by itself. As a backup disk, k1boot has two dedicated HDD for full and differential backups as follows.
$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 69G 57G 8.5G 87% / udev 10M 208K 9.8M 3% /dev /dev/sde1 917G 224G 647G 26% /mnt/backup /dev/sdc1 917G 224G 648G 26% /opt /dev/sdb1 1.8T 457G 1.3T 27% /mnt/diff_backup shm 32G 0 32G 0% /dev/shm
