Add instructions for zerofree

This commit is contained in:
Milkey Mouse 2017-11-09 20:36:39 -08:00
parent 2b254abb39
commit b0d68036c2
No known key found for this signature in database
GPG Key ID: C6EF5A02F5647987
1 changed files with 22 additions and 1 deletions

View File

@ -103,9 +103,30 @@ Restoration is similar to the above process, but done in reverse::
DISK=$(losetup -Pf --show /path/to/disk/image)
# do backup as shown above
sync $DISK
losetup -d $DISK
Using zerofree (ext2, ext3, ext4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
zerofree works similarly to ntfsclone in that it zeros out unused chunks of the FS, except
that it works in place, zeroing the original partition. This makes the backup process a bit
simpler::
sfdisk -lo Device,Type $DISK | sed -e '1,/Device\s*Type/d' | grep Linux | cut -d' ' -f1 | xargs -n1 zerofree
borg create --read-special repo::hostname-disk $DISK
Because the partitions were zeroed in place, restoration is only one command::
borg extract --stdout repo::hostname-disk | dd of=$DISK
.. note:: The "traditional" way to zero out space on a partition, especially one already
mounted, is to simply ``dd`` from ``/dev/zero`` to a temporary file and delete
it. This is ill-advised for the reasons mentioned in the ``zerofree`` man page:
- it is slow
- it makes the disk image (temporarily) grow to its maximal extent
- it (temporarily) uses all free space on the disk, so other concurrent write actions may fail.
Can I backup from multiple servers into a single repository?
------------------------------------------------------------