Difference between revisions of "Linux: incremental backup using rsync on btrfs with snapshots"
Lukas Dzunko (talk | contribs) (→iSCSI configuration) |
Lukas Dzunko (talk | contribs) (→iSCSI discovery and login) |
||
Line 30: | Line 30: | ||
</pre> | </pre> | ||
There should be new disk once kernel detect it: | There should be new disk once kernel detect it: | ||
+ | <pre> | ||
+ | scsi8 : iSCSI Initiator over TCP/IP | ||
+ | scsi 8:0:0:0: Direct-Access SYNOLOGY iSCSI Storage 3.1 PQ: 0 ANSI: 5 | ||
+ | sd 8:0:0:0: Attached scsi generic sg2 type 0 | ||
+ | sd 8:0:0:0: [sdb] 104857600 512-byte logical blocks: (53.6 GB/50.0 GiB) | ||
+ | sd 8:0:0:0: [sdb] Write Protect is off | ||
+ | sd 8:0:0:0: [sdb] Mode Sense: 3b 00 00 00 | ||
+ | sd 8:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA | ||
+ | sdb: unknown partition table | ||
+ | sd 8:0:0:0: [sdb] Attached SCSI disk | ||
+ | </pre> | ||
<pre> | <pre> | ||
# lsscsi | grep SYN | # lsscsi | grep SYN | ||
[6:0:0:0] disk SYNOLOGY iSCSI Storage 3.1 /dev/sdb | [6:0:0:0] disk SYNOLOGY iSCSI Storage 3.1 /dev/sdb | ||
</pre> | </pre> | ||
+ | |||
=== filesystem === | === filesystem === | ||
I prefer disk labels as device file may change over time: | I prefer disk labels as device file may change over time: |
Revision as of 15:53, 21 February 2014
My production data are backed up by bacula. This is good for data "online" all the time, but it is not so convent for my notebook and media PC. Till now I was using only simple rsync script to "copy" everything important to USB drive or iSCSI LUN. This solution was working fine but hat one catch. There is no way how to retrieve older version of files.
I would like to have possibility to retrieve also older versions of files so i combined my rsync backup with btrfs and snapshot feature. Here is result:
Contents
Before first backup
I am using iSCSI lun as target for backup. Skip iSCSI part if you are using USB drive.
iSCSI configuration
It is important to password protect Target. Otherwise any device on local network can overwrite it. Also I highly recommend Header and Data digest. There is possibility of data corruption without it.
Configuration of iSCSI initiator is stored in /etc/iscsi/iscsid.conf
. Following lines are mandatory:
node.session.auth.authmethod = CHAP node.session.auth.username = <user> node.session.auth.password = <pass> node.conn[0].iscsi.HeaderDigest = CRC32C node.conn[0].iscsi.DataDigest = CRC32C
All others can be left in "default" configuration.
iSCSI discovery and login
It is necessary to discover iSCSI target and log to it before system can access drive. It can be performed by following commands:
# iscsiadm -m discovery -t st -p prue-nas 10.xx.xx.5:3260,0 iqn.2000-01.com.synology:prue-nas.phoebe 10.xx.xx.5:3260,0 iqn.2000-01.com.synology:prue-nas.lukas # iscsiadm -m node -T iqn.2000-01.com.synology:prue-nas.phoebe --login Logging in to [iface: default, target: iqn.2000-01.com.synology:prue-nas.phoebe, portal: 10.xx.xx.5,3260] Login to [iface: default, target: iqn.2000-01.com.synology:prue-nas.phoebe, portal: 10.xx.xx.5,3260] successful.
There should be new disk once kernel detect it:
scsi8 : iSCSI Initiator over TCP/IP scsi 8:0:0:0: Direct-Access SYNOLOGY iSCSI Storage 3.1 PQ: 0 ANSI: 5 sd 8:0:0:0: Attached scsi generic sg2 type 0 sd 8:0:0:0: [sdb] 104857600 512-byte logical blocks: (53.6 GB/50.0 GiB) sd 8:0:0:0: [sdb] Write Protect is off sd 8:0:0:0: [sdb] Mode Sense: 3b 00 00 00 sd 8:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA sdb: unknown partition table sd 8:0:0:0: [sdb] Attached SCSI disk
# lsscsi | grep SYN [6:0:0:0] disk SYNOLOGY iSCSI Storage 3.1 /dev/sdb
filesystem
I prefer disk labels as device file may change over time:
# mkfs.btrfs -L phoebe-backup /dev/sdb Turning ON incompat feature 'extref': increased hardlink limit per file to 65536 fs created label phoebe-backup on /dev/sdb nodesize 16384 leafsize 16384 sectorsize 4096 size 50.00GiB Btrfs v3.12
fstab
- data backup
LABEL=phoebe-backup /mnt/backup btrfs noauto 0 0
mkdir -p /mnt/backup mount /mnt/backup
subvolume
- btrfs sub create /mnt/backup/phoebe
Create subvolume '/mnt/backup/phoebe'