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 [2019/04/10 04:03] oemb1905computing:rsyncrsnapshot [2020/01/27 19:55] 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.  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/ 
-  sudo nano fstab 
-  <Edit the drive UUID of the new destination drive> 
-   
-Now, make the destination volume bootable: 
  
-  grub-install /dev/sdX 
-   
-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, 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. 
  
-rsync over ssh 
  
-  sudo rsync -avHe --delete -e 'ssh -p 53213' user@172.39.58.38:/home/Archives/+Making an rsync over ssh mirror using alternate port and the old syntax.
-  sudo rsync -avWeqr --delete -e 'ssh -p 59999' /home/source/ user@10.18.18.2:/media/sdb1/back/ +
-   +
-That last one works perfectly ... but no matter what, I was having it prompt me for a password despite normal ssh working fine without one+
  
-[Update]+From remote server to target backup localhost:
  
-Here is how I got rsync over pub key authentication (no password prompt) working properly on Debian 9.7 This is an answer on Stack Exchange:+  rsync -av --delete -e 'ssh -p 59333 -i /home/user/.ssh/id_rsa' user@10.8.9.3:/home/user/Server/ /home/user/Server/
  
-The examples provided as answers here either provide an alternate solutions or make the official solution unclear. Here are two examples with explicit path examples and entries so people can adjust for their needs without interpreting obtuse bash notation:+From localhost to target remote backup server
  
-Execute this from the target backup machine, which pulls from source to target backup+  rsync -av --delete -e 'ssh -p 59333 -i /home/user/.ssh/id_rsa' /home/user/Server/ user@10.8.9.3:/home/user/Server/ 
 +   
 +-- -- -- -- -- 
  
-  rsync -avWeqr --delete -e 'ssh -p 59333 -i /home/user/.ssh/id_rsa' user@10.1.999.3:/home/user/Server/ /home/user/Server/+Using the more modern syntax and no alternate port, we have:
  
-Execute this from the source machine, which sends from source to target backup+From remote server to target backup localhost:
  
-  rsync -avWeqr --delete -e 'ssh -p 59333 -i /home/user/.ssh/id_rsa' /home/user/Serveruser@10.1.999.3:/home/user/Server/+  sudo rsync -avi --delete root@server.com:/home/location/of/mysqldump.sql /home/user/backup/of/mysqldump.sql 
  
-Since ssh public key authentication is a requirement for this question's answer, the solution is in telling rsync where to locate the private key, that matches an authorized public key on the destination server. You can create specific ssh keys on each end if you are a security freak, or even distinct keys just for the rsync use that differ from your user. But this is a bit complicated and not needed if these hosts are behind a firewall on a secure LAN. In that case, I recommend using the same ssh public/private keypair on both machines.+From localhost to target remote backup server
  
-Also, I might add that the initial rsync flags, are to an extent, optional, but the specific arrangement `-avWeqr`, was needed for me in order to get `--delete` working properly with all the other parametersThese were tested on Debian 9.7 and work.+  sudo rsync -avi --delete /home/user/backup/of/mysqldump.sql root@server.com:/home/location/of/mysqldump.sql 
 +  
  
-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]]. 
  
- --- //[[netcmnd@jonathanhaack.com|oemb1905]] 2019/04/09 19:26//+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]].
  
 + --- //[[oemb1905@jonathanhaack.com|oemb1905]] 2019/07/31 09:53//
      
computing/rsyncrsnapshot.txt · Last modified: 2023/04/10 21:29 by oemb1905