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 [2020/01/27 20:08] oemb1905computing:rsyncrsnapshot [2023/04/10 21:03] oemb1905
Line 7: Line 7:
 ------------------------------------------- -------------------------------------------
  
-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:+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 ''/etc/rsnapshot.conf'' together with the localhost/backup server. I have the config set to retain 90 days worth of backups called "alpha" and it is set to sync first. The localhost configuration is as follows: 
 + 
 +  #base config  
 +  config_version          1.2 
 +  snapshot_root           /mnt/backups/rsnapback/localhost.domain/ 
 +  cmd_cp                  /bin/cp 
 +  cmd_rm                  /bin/rm 
 +  cmd_rsync               /usr/bin/rsync 
 +  cmd_ssh                 /usr/bin/ssh 
 +  cmd_logger              /usr/bin/logger 
 +  verbose                 2 
 +  loglevel                3 
 +  logfile                 /var/log/rsnapshot.log 
 +  sync_first              1 
 +  use_lazy_deletes        1  
 +  retain                  alpha                                           90 
 +  #localhost 
 +  backup                  /home/                                          home/ 
 +  backup                  /etc/                                           etc/ 
 +  backup                  /usr/local/bin/                                 bin/ 
 +  backup                  /root/                                          root/ 
 +  backup                  /var/www/                                       www/ 
 +   
 +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's single desktop: 
 + 
 +  #!/bin/bash 
 +  service="/usr/bin/rsnapshot" 
 +  logfile="/home/logs/tempa.log" 
 +          START1="$(date +%s)" 
 +          touch $logfile 
 +          $service -V sync > $logfile 
 +          END1="$(date +%s)" 
 +          DURATION1=$[ ${END1} - ${START1} ] 
 +          MINUTES=$[ ${DURATION1} / 60 ] 
 +          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 "completed" 
 +  then 
 +          START1="$(date +%s)" 
 +          echo "Jonathan, at $(date), the sync has completed and I am now running alpha." 
 +          $service -V alpha >> $logfile 
 +          END1="$(date +%s)" 
 +          DURATION1=$[ ${END1} - ${START1} ] 
 +          MINUTES=$[ ${DURATION1} / 60 ] 
 +          sed -i "1s/^/Jonathan, at $(date), the rsnapshot alpha took exactly ${DURATION1} seconds which is approximately ${MINUTES} minutes to complete.\n/" $logfile 
 +          mail -s "[$(hostname -f)]-rsnap-success-$(date)" alerts@alerts.com < $logfile 
 +          rm $logfile 
 +          chown sexa:sexa -R /mnt/backups/rsnapback/localhost.domain/ 
 +          chmod 770 -R /mnt/backups/rsnapback/localhost.domain/ 
 +  else 
 +          echo "Jonathan, at $(date), the sync has failed and I am now notifying you." 
 +          mail -s "[$(hostname -f)]-rsnap-failure-$(date)" alerts@alerts.com < $logfile 
 +          rm $logfile 
 +  fi 
 + 
 + 
 + 
 +[BEGIN OLD] 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:
  
   sudo apt install rsnapshot   sudo apt install rsnapshot
Line 23: Line 80:
   <backup /etc/    localhost>   <backup /etc/    localhost>
  
-Now, edit the default script inside ''cron.d'' and for, simple configurations, just enable the four entries they have inside that template.  The default cron entries look like this:+Now, edit the default script inside ''/etc/cron.d/rsnapshot'' and for, simple configurations, just enable the four entries they have inside that template.  The default cron entries look like this:
  
   <0 */4   * * *          root    /usr/bin/rsnapshot alpha>   <0 */4   * * *          root    /usr/bin/rsnapshot alpha>
Line 55: Line 112:
  
   sudo rsync -avi --delete /home/user/backup/of/mysqldump.sql root@server.com:/home/location/of/mysqldump.sql   sudo rsync -avi --delete /home/user/backup/of/mysqldump.sql root@server.com:/home/location/of/mysqldump.sql
-   + 
-Enjoy.+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.
  
 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]]. 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]].
computing/rsyncrsnapshot.txt · Last modified: 2023/04/10 21:29 by oemb1905