This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
computing:rsyncrsnapshot [2018/11/27 01:00] – oemb1905 | computing:rsyncrsnapshot [2023/04/10 21:12] – oemb1905 | ||
---|---|---|---|
Line 7: | Line 7: | ||
------------------------------------------- | ------------------------------------------- | ||
- | sudo rsync -avxHAX --progress --delete | + | Since I am backing up multiple remote hosts, I chose to create separate configs for each remote host instead of putting those destinations in the '' |
- | Adding | + | #base config |
- | + | config_version | |
- | | + | snapshot_root |
+ | cmd_cp | ||
+ | cmd_rm | ||
+ | cmd_rsync | ||
+ | cmd_ssh | ||
+ | cmd_logger | ||
+ | verbose | ||
+ | loglevel | ||
+ | logfile | ||
+ | | ||
+ | | ||
+ | retain | ||
+ | # | ||
+ | backup | ||
+ | | ||
+ | backup | ||
+ | backup | ||
+ | backup | ||
| | ||
- | Cloning entire drives, use: | + | Then, to run this, I use a simple script I created. Again, this script is just for running the localhost, so it can also be used for someone' |
- | | + | |
- | + | service=" | |
- | If the drive you are cloning from has a different filesystem than the destination drive, | + | logfile="/ |
+ | START1=" | ||
+ | touch $logfile | ||
+ | $service | ||
+ | END1=" | ||
+ | DURATION1=$[ ${END1} | ||
+ | MINUTES=$[ ${DURATION1} | ||
+ | sed -i "1s/^/Jonathan, at $(date), the rsnapshot sync took exactly ${DURATION1} seconds which is approximately ${MINUTES} minutes to complete.\n/" $logfile | ||
+ | if | ||
+ | tail -n -5 $logfile | grep " | ||
+ | then | ||
+ | START1=" | ||
+ | echo " | ||
+ | $service -V alpha >> $logfile | ||
+ | END1=" | ||
+ | DURATION1=$[ ${END1} - ${START1} ] | ||
+ | MINUTES=$[ ${DURATION1} | ||
+ | sed -i "1s/^/Jonathan, at $(date), the rsnapshot alpha took exactly ${DURATION1} seconds which is approximately ${MINUTES} minutes to complete.\n/" $logfile | ||
+ | mail -s " | ||
+ | rm $logfile | ||
+ | chown sexa:sexa -R /mnt/backups/rsnapback/ | ||
+ | chmod 770 -R /mnt/backups/rsnapback/localhost.domain/ | ||
+ | | ||
+ | echo " | ||
+ | mail -s " | ||
+ | rm $logfile | ||
+ | fi | ||
- | cd /etc/ | + | Then, in '' |
- | sudo nano fstab | + | |
- | <Edit the drive UUID of the new destination drive> | + | |
- | + | ||
- | Now, make the destination volume bootable: | + | |
- | | + | |
- | + | ||
- | If you are using this method to clone your existing server to another hard drive on the same host, then make sure to run //grub-update// on the primary OS. After you do that, both the kernels for the primary OS and the cloned OS will appear in GRUB, and you can boot into the clone, specifically, | + | |
- | rsync over ssh | + | Now that the localhost/ |
- | | + | |
+ | config_version | ||
+ | snapshot_root | ||
+ | cmd_cp | ||
+ | cmd_rm | ||
+ | cmd_rsync | ||
+ | cmd_ssh | ||
+ | cmd_logger | ||
+ | verbose | ||
+ | loglevel | ||
+ | logfile | ||
+ | sync_first | ||
+ | use_lazy_deletes | ||
+ | retain | ||
+ | # | ||
+ | backup | ||
+ | backup | ||
+ | backup | ||
+ | backup | ||
+ | backup | ||
+ | |||
+ | Now that the config is setup, you use a script very similar to the localhost script above, but note the syntax changes for sync and alpha that will specify to rsnapshot to use this particular configuration file: | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | [BEGIN OLD] Let's start with rsnapshot. | ||
+ | |||
+ | sudo apt install rsnapshot | ||
+ | nano / | ||
+ | < | ||
+ | |||
+ | Uncomment the alpha, beta, gamma, and delta sections under //backup levels// section, enable the sync-first option, and specify the directories you want to backup (remember, | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |||
+ | Now, edit the default script inside ''/ | ||
+ | |||
+ | <0 */4 * * * root / | ||
+ | <30 3 * * * root / | ||
+ | <0 3 * * 1 root / | ||
+ | <30 2 1 * * root / | ||
| | ||
- | That last one works perfectly | + | Personally, I use a simple script to ensure that the sync_first command completed before I run any of the '' |
- | + | ||
- | https://opensource.com/article/17/1/rsync-backup-linux | + | [[https://repo.haacksnetworking.com/oemb1905/haackingclub/blob/master/ |
- | https://github.com/opensourceway/ | + | |
- | https://gist.github.com/enoch85/45eba73c49f760905bc2 | + | Of course, I have one of these for alpha, another for beta, and gamma, and so on until delta. |
+ | |||
+ | [[https://repo.haacksnetworking.com/oemb1905/haackingclub/ | ||
+ | |||
+ | OK ... that's pretty much it for getting started with rsnapshot. | ||
+ | |||
+ | From remote server to target backup localhost, with alt port: | ||
+ | |||
+ | | ||
+ | |||
+ | From localhost to target remote | ||
+ | |||
+ | rsync -av --delete -e 'ssh -p 59333 -i / | ||
+ | |||
+ | From remote server to target backup localhost, with standard port: | ||
+ | |||
+ | sudo rsync -avi --delete root@server.com:/home/location/ | ||
+ | |||
+ | From localhost to target remote backup server, with standard port: | ||
+ | |||
+ | sudo rsync -avi --delete / | ||
+ | |||
+ | Once you master these steps, checkout remote-upgrades, | ||
- | --- //[[netcmnd@jonathanhaack.com|oemb1905]] 2018/11/22 12:56// | + | This tutorial is a designated " |
+ | --- // | ||
| |