User Tools

Site Tools


computing:rsyncrsnapshot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
computing:rsyncrsnapshot [2018/11/26 18:37] oemb1905computing:rsyncrsnapshot [2020/03/26 01:29] oemb1905
Line 7: Line 7:
 ------------------------------------------- -------------------------------------------
  
-  sudo rsync -avxHAX --progress --delete /sourcefiles/path /backup/path+Let's start with rsnapshot.  Before you begin, you must already know how to add a hard drive to your system, a mount point, and an appropriate fstab entry.  This also assumes you have an MTA properly set-up in order to send email.  To create a basic configuration, do the following:
  
-Adding //h//, //H//, //P//, will preserve hard links, give you human readable output, and show the progress (eliminating the need for --progress).+  sudo apt install rsnapshot 
 +  nano /etc/rsnapshot.conf 
 +  <rsnapshot_root /enter-mount-point-here>
  
-  sudo rsync -avxHAXhHP --delete /sourcefiles/path /backup/path +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, ''localhost''calls whatever you have above in ''rsnapshot_root'' from above):
-   +
-Cloning entire drivesuse:+
  
-  sudo rsync -avxHAXhHP --delete /sourcefiles/path /backup/path --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found} +  <retain  alpha   6> 
-   +  <retain  beta    7> 
-If the drive you are cloning from has a different filesystem than the destination drive, you can remove the exclusions as //-x// will handle those exclusions in that case.  After cloning, you will need to adjust fstab on the destination partition:+  <retain  gamma   4> 
 +  <retain  delta   3> 
 +  <sync_first      1> 
 +  <backup /home  localhost> 
 +  <backup /etc   localhost>
  
-  cd /etc/ +Now, edit the default script inside ''/etc/cron.d/rsnapshot'' and forsimple configurations, just enable the four entries they have inside that template.  The default cron entries look like this:
-  sudo nano fstab +
-  <Edit the drive UUID of the new destination drive> +
-   +
-Nowmake the destination volume bootable:+
  
-  grub-install /dev/sdX+  <0 */4   * * *          root    /usr/bin/rsnapshot alpha> 
 +  <30 3    * * *          root    /usr/bin/rsnapshot beta> 
 +  <0  3    * * 1          root    /usr/bin/rsnapshot gamma> 
 +  <30 2    1 * *          root    /usr/bin/rsnapshot delta>
      
-If you are using this method to clone your existing server to another hard drive on the same hostthen 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 GRUBand you can boot into the clonespecifically, to make sure that everything migrated properly and is in working order.  It is not sufficient to simply run rsync and hope that all went well.+PersonallyI use a simple script to ensure that the sync_first command completed before I run any of the ''rsnapshot alpha''or ''rsnapshot beta'', and so on.  My script is simple and limited to what I could get up and working There are reliability problems with this script in full disclosure, but for my use case, it works at present.  Here it is:
  
-rsync over ssh+[[https://repo.haacksnetworking.com/oemb1905/haackingclub/blob/master/rsnapshot/rsnap-alpha.sh|rsnapshot-scripts]]
  
-  rsync -avxHAXhHP --delete 'ssh -p 53333' user@remotemachine:/home/user/*.zip /path/to/dir/on/localhost +Of course, I have one of these for alpha, another for beta, and gamma, and so on until delta.  Each of these checks the verbose log for successful completion and emails me upon verification of that from the output of the ''rsnapshot sync_first'' command.  If it fails, it stops the service and emails me.  A colleague of mine has a much more advanced script that checks whether the drive is mounted and other various niceties that should be part of a more robust backup solution.  I have included a version of the script he developed and shared with me here: 
-  sudo rsync -avHe --delete -e 'ssh -p 53213sexa@172.39.58.38:/home/Archives. + 
-   +[[https://repo.haacksnetworking.com/oemb1905/haackingclub/blob/master/backups/jsbk.sh|jbsk.sh]] 
-That last one works perfectly ... + 
-   +OK ... that's pretty much it for getting started with rsnapshot.  Now, let's look at rsync over ssh, which is a great way to pull an immediate mirror of a site with ease.  I have included syntax for alternate port and newer syntax without alternate port. 
-https://opensource.com/article/17/1/rsync-backup-linux + 
-https://github.com/opensourceway/rsync-backup-script +From remote server to target backup localhost, with alt port: 
-https://gist.github.com/enoch85/45eba73c49f760905bc2+ 
 +  rsync -av --delete -e 'ssh -p 59333 -i /home/user/.ssh/id_rsa' user@10.8.9.3:/home/user/Server/ /home/user/Server/ 
 + 
 +From localhost to target remote backup server, with alt port:  
 + 
 +  rsync -av --delete -e 'ssh -p 59333 -i /home/user/.ssh/id_rsa/home/user/Server/ user@10.8.9.3:/home/user/Server
 + 
 +From remote server to target backup localhost, with standard port: 
 + 
 +  sudo rsync -avi --delete root@server.com:/home/location/of/mysqldump.sql /home/user/backup/of/mysqldump.sql  
 + 
 +From localhost to target remote backup server, with standard port:  
 + 
 +  sudo rsync -avi --delete /home/user/backup/of/mysqldump.sql root@server.com:/home/location/of/mysqldump.sql 
 + 
 +Once you master these steps, checkout remote-upgrades, so you can use these backup scripts and tools with a greater remote vpn and backup solution.
  
- --- //[[netcmnd@jonathanhaack.com|oemb1905]] 2018/11/22 12:56//+This tutorial is a designated "Invariant Section" of the "Technotronic" section of Haack's Wiki as described on the [[https://jonathanhaack.com/dokuwiki/doku.php?id=start|Start Page]].
  
 + --- //[[jonathan@haacksnetworking.com|oemb1905]] 2020/01/27 12:55//
      
computing/rsyncrsnapshot.txt · Last modified: 2023/04/10 21:29 by oemb1905