User Tools

Site Tools


public:using_btrbk_to_backup_my_home_partition

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
public:using_btrbk_to_backup_my_home_partition [2017/07/05 23:41] – [Btrbk configuration] fangfufupublic:using_btrbk_to_backup_my_home_partition [2018/03/31 00:38] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Using Btrbk to backup my home partition ====== ====== Using Btrbk to backup my home partition ======
-Due to the [[public:2017-06-14_data_extinction_event_investigation_report|fiasco]] of running ''rm -rf'' on my home partition, and wiping out all my backup snapshots, I realised that it is important to have some sort of offline backups. Snapper [([[http://snapper.io/|Snapper, The ultimate Snapshot Tool for Linux]])] creates snapshots, but manual operations are required to move those snapshots off to external backup devices (in order to offline backups). A better solution is desperately needed. I discovered Btrbk [([[https://github.com/digint/btrbk|GitHub - digint/btrbk: Tool for creating snapshots and remote backups]])]. +Due to the [[public:2017-06-14_data_extinction_event_investigation_report|fiasco]] of running ''rm -rf'' on my home partition, and wiping out all my backup snapshots, I realised that it is important to have some sort of offline backups. Snapper [([[http://snapper.io/|Snapper, The ultimate Snapshot Tool for Linux]])] creates snapshots, but manual operations are required to move those snapshots off to external backup devices (in order to offline backups). A better solution is desperately needed. I discovered Btrbk [(btrbk_github > 
 + [[https://github.com/digint/btrbk|GitHub - digint/btrbk: Tool for creating snapshots and remote backups]])]. 
  
 It is much harder to understand, please read the man page. I am just going to document what I did to my own machine.  It is much harder to understand, please read the man page. I am just going to document what I did to my own machine. 
Line 26: Line 27:
 Here is my Btrbk configuration: Here is my Btrbk configuration:
 <code> <code>
 +lockfile                   /var/lock/btrbk.lock
 transaction_log            /var/log/btrbk.log transaction_log            /var/log/btrbk.log
 timestamp_format           long-iso timestamp_format           long-iso
-lockfile                   /var/lock/btrbk.lock 
  
 volume /mnt/home volume /mnt/home
         snapshot_preserve       24h 7d 4w         snapshot_preserve       24h 7d 4w
-        snapshot_preserve_min   1d+        snapshot_preserve_min   latest 
 +        target_preserve         24h 30d 
 +        target_preserve_min     latest
         snapshot_dir snapshots         snapshot_dir snapshots
         subvolume home         subvolume home
 +                target send-receive /mnt/storage/home-backups
  
-volume /mnt/home +volume ssh://127.0.0.1/mnt/home 
-        snapshot_preserve       no +        ssh_identity /root/.ssh/id_rsa 
-        snapshot_preserve_min   latest +        target_preserve         180d 
-        target_preserve         no +        target_preserve_min     latest 
-        target_preserve         6m +        snapshot_create         no 
-        snapshot_dir offline_snapshots +        snapshot_dir snapshots
-        snapshot_create ondemand+
         subvolume home         subvolume home
-        target send-receive /media/fangfufu/Hitachi500GB/home-backups</code>+                target send-receive /media/fangfufu/WD500GB/home-backups 
 +                target send-receive /media/fangfufu/Seagate500GB/home-backups 
 +</code> 
 + 
 +Basically, my laptop is configured to save 24 hourly snapshots, 7 daily snapshots, 4 weekly snapshots. The external backup drive has 6 months of snapshots. 
  
-Basicallymy laptop is configured to save 24 hourly snapshots, 7 daily snapshots, 4 weekly snapshots. The external backup drive has 6 months of snapshotsNote that you need two entries for the same subvolume to enable on-demand creation of the offline snapshots. Otherwise the Btrbk throws warnings in Cron +The extra ''[[ssh://127.0.0.1/mnt/home]]'' paragraph basically follows the "Example: multiple btrbk instances" on the btrbk's Github page[(btrbk_github)]. This allows ''snapshot_dir'' to get cleared up locally. If you write everything in one paragraphthen btrbk refuses to clean up snapshots, because external hard drives are not connectedIf you write another paragraph of ''volume /mnt/home'', then btrbk complains that the two snapshots are created at the same directory. The side effect of that is the funny ''ssh'', ''sshd'', ''btrfs-send'', ''btrfs-receive'' CPU usage, when sending snapshot to external drives
  
 ===== Doing backup ===== ===== Doing backup =====
Line 53: Line 60:
 <code> <code>
 #!/bin/sh #!/bin/sh
-exec /usr/sbin/btrbk -q run+echo > /var/log/btrbk.log 
 +/usr/sbin/btrbk -q run > /dev/null 2>&
 +return 0 
 +#returning 0 to suppress cron warning emails.  
 </code> </code>
  
Line 64: Line 74:
  
 <code> <code>
-root@smithsonian:~# btrbk run+btrbk command line client, version 0.25.0  (Fri Jul  7 09:27:21 2017) 
 +Using configuration: /etc/btrbk/btrbk.conf 
 +WARNING: Skipping target "/media/fangfufu/Hitachi500GB/home-backups": Failed to fetch subvolume detail 
 +WARNING: Skipping target "/media/fangfufu/Seagate500GB/home-backups": Failed to fetch subvolume detail 
 +Using transaction log: /var/log/btrbk.log 
 +Creating subvolume snapshot for: /mnt/home/home 
 +[snapshot] source: /mnt/home/home 
 +[snapshot] target: /mnt/home/snapshots/home.20170707T092721+0100 
 +Cleaning snapshots: /mnt/home/snapshots/home.* 
 +Deleted 0 subvolumes in: /mnt/home/snapshots/home.* 
 +WARNING: Skipping cleanup of snapshots for subvolume "127.0.0.1:/mnt/home/home", as at least one target aborted earlier 
 +Completed within: 0s  (Fri Jul  7 09:27:21 2017)
 -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
 Backup Summary (btrbk command line client, version 0.25.0) Backup Summary (btrbk command line client, version 0.25.0)
  
-    Date:   Wed Jul  5 22:08:18 2017+    Date:   Fri Jul  7 09:27:21 2017
     Config: /etc/btrbk/btrbk.conf     Config: /etc/btrbk/btrbk.conf
  
Line 79: Line 100:
 -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
 /mnt/home/home /mnt/home/home
-+++ /mnt/home/snapshots/home.20170705T220818+0100 ++++ /mnt/home/snapshots/home.20170707T092721+0100 
-*** /media/fangfufu/Hitachi500GB/home.20170705T220818+0100 + 
-</code>+127.0.0.1:/mnt/home/home 
 +!!! Target "/media/fangfufu/Hitachi500GB/home-backups" aborted: Failed to fetch subvolume detail 
 +!!! Target "/media/fangfufu/Seagate500GB/home-backups" aborted: Failed to fetch subvolume detail 
 + 
 +NOTE: Some errors occurred, which may result in missing backups! 
 +Please check warning and error messages above.</code>
  
 ===== Accesing snapshots ===== ===== Accesing snapshots =====
public/using_btrbk_to_backup_my_home_partition.1499298068.txt.gz · Last modified: 2018/03/31 00:38 (external edit)