Successfully reported this slideshow.

Barcamp Gent 2: rsnapshot

1,987 views

Published on

automated, easy and green backups with rsnapshot

Published in: Technology
  • Be the first to comment

Barcamp Gent 2: rsnapshot

  1. 1. rsnapshot easy and automated backup/restore, snapshot style
  2. 2. This is not about <ul><li>Backup strategy </li></ul><ul><ul><li>What and when </li></ul></ul><ul><ul><li>overhead? </li></ul></ul><ul><li>I just had a crash, please help me </li></ul>
  3. 3. Classic trade-off <ul><li>Full backup </li></ul><ul><ul><li>Large backup time </li></ul></ul><ul><ul><li>Quick and easy restore </li></ul></ul><ul><ul><li>Space consuming </li></ul></ul><ul><li>Incremental backups </li></ul><ul><ul><li>Quick backup </li></ul></ul><ul><ul><li>Complex and time consuming restore </li></ul></ul><ul><ul><li>More space efficient </li></ul></ul>
  4. 4. rsnapshot <ul><li>Combines full and incremental backups </li></ul><ul><ul><li>But off course only the good things </li></ul></ul><ul><li>Quick backup process </li></ul><ul><li>Quick and easy restore </li></ul><ul><li>Space efficient </li></ul><ul><li>Remote, on harddisks, no tape switching </li></ul>
  5. 5. Amazing! But how? <ul><li>I'll explain you! </li></ul>
  6. 6. Built on two key concepts <ul><li>Rsync </li></ul><ul><li>Hardlinks </li></ul>
  7. 7. rsync <ul><li>synchronizes files and directories </li></ul><ul><li>minimizing data transfer using delta encoding </li></ul><ul><li>optionally using compression and recursion. </li></ul><ul><li>daemon </li></ul><ul><li>native rsync protocol or SSH </li></ul><ul><li>free software </li></ul><ul><li>default on most UNIXs </li></ul>
  8. 8. Hardlinks <ul><li>pointer to a file on a storage volume </li></ul><ul><li>more than one name can be associated with the same file </li></ul><ul><li>supported on UNIX's, Windows NT OS's </li></ul><ul><li>delete file = decrease link counter </li></ul><ul><ul><li>counter = 0: delete data </li></ul></ul>
  9. 9. rsnapshot <ul><li>Set of perl scripts </li></ul><ul><li>Calls rsync on regular base (cron) </li></ul><ul><ul><li>Only changed files transferred </li></ul></ul><ul><ul><li>Local, remote, ssh,... </li></ul></ul><ul><li>Creates hardlinks to unchanged files </li></ul><ul><ul><li>So every run delivers a full snapshot of the complete directory structure </li></ul></ul><ul><ul><li>Only using diskspace of 1 full system + changes </li></ul></ul><ul><ul><li>Restore: just copy the files/dirs of the snapshot </li></ul></ul>
  10. 10. Practice: /etc/rsnapshot.conf <ul><ul><li>Intervals </li></ul></ul><ul><ul><ul><li>Interval daily 7 </li></ul></ul></ul><ul><ul><ul><li>Interval weekly 4 </li></ul></ul></ul><ul><ul><li>Exclude files </li></ul></ul><ul><ul><li>Backup dirs </li></ul></ul><ul><ul><ul><li>Backup /etc/ localhost/ </li></ul></ul></ul><ul><ul><ul><li>Backup root@leffe:/data leffe/ </li></ul></ul></ul><ul><ul><ul><li>Backup rsync://host/dir/ hostname/ </li></ul></ul></ul><ul><ul><li>Backup scripts </li></ul></ul><ul><ul><ul><li>backup_script /root/mysqlbackup_leffe.sh leffe/mysqlbackup/ </li></ul></ul></ul>
  11. 11. My own little setup
  12. 12. My own little setup <ul><li>WD MyBook = backup server </li></ul><ul><li>Daily, weekly, monthly backup </li></ul><ul><li>Wrapped in WoL script </li></ul><ul><li>Backup over SSH </li></ul><ul><ul><li>Secure? Root access? </li></ul></ul><ul><ul><li>See next slide </li></ul></ul><ul><li>Backupscripts: MySQL DB and dpkg package list </li></ul><ul><ul><li>Enables quick recovery of software on ubuntu/linux </li></ul></ul>
  13. 13. SSH security <ul><li>Non-interactive, only key-based login without passwords </li></ul><ul><li>Dedicated key for root </li></ul><ul><ul><li>In authorized_keys file on client </li></ul></ul><ul><ul><li>IP-restriction: from=&quot;192.168.3.252&quot; </li></ul></ul><ul><ul><li>Command restriction: command=&quot;/root/validatescript&quot; </li></ul></ul><ul><ul><ul><li>Validatescript returns original command or Rejected </li></ul></ul></ul><ul><ul><ul><li>My setup: only “rsync –server”, “dpkg –get-selections”, “pm-suspend” and “db-backup” allowed </li></ul></ul></ul>
  14. 14. My experiences <ul><li>WD MyBook is a very slow device (CPU) </li></ul><ul><ul><li>Possible optimisation: let script enable native rsync and disable after backup </li></ul></ul><ul><li>First backup took some time </li></ul><ul><li>Daily (“incremental”) backups are quite fast </li></ul><ul><li>Watch out for rollback! </li></ul>
  15. 15. Conclusion <ul><li>Quite easy and very extensible </li></ul><ul><li>More info: www.rsnapshot.org </li></ul><ul><li>more info on hacking WD: http://mybookworld.wikidot.com/ </li></ul>
  16. 16. Thank you very much! Questions?

×