Introduction to ZPAQ - Remote backups (using an index)
So far we've gone through the ZPAQ basics and saw how to create incremental backups.
In this post I'll be taking a look at remote backups.
To demonstrate this, I'm going to mount a remote filesystem using SSHFS.
1. Install SSHFS
yum install epel-release -y
yum install fuse-sshfs -y
2. Create a directory to use as mount point - this is where we'll send all our output files
mkdir /mnt/zpaq-archives
3. Mount it using SSHFS (this assumes you've already set up key-based authentication and that on the other host you've already created the /var/zpaq-archives directory)
sshfs root@104.245.36.97:/var/zpaq-archives /mnt/zpaq-archives
In my case the output of df -hT
now shows the following:
[root@zpaq1 .ssh]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext4 79G 738M 74G 1% /
tmpfs tmpfs 939M 0 939M 0% /dev/shm
root@104.245.36.97:/var/zpaq-archives
fuse.sshfs 79G 682M 74G 1% /mnt/zpaq-archives
4. Now let's install ZPAQ - I got the RPMS for CentOS from here: http://software.opensuse.org/download.html?project=home:antonbatenev:zpaq-upstream&package=zpaq-upstream
yum install http://download.opensuse.org/repositories/home:/antonbatenev:/zpaq-upstream/ScientificLinux_6/x86_64/zpaq-upstream-7.13-3.1.x86_64.rpm -y
5. Cool - now let's create our first full archive - we'll save the archive itself on SSHFS (/mnt/zpaq-archives) and the index locally under /root
zpaq add /mnt/zpaq-archives/zpaq-backup-of-etc? /etc/ -index /root/zpaq-backup-of-etc-index.zpaq
6. Check the resulting size of the full backup and the index:
Full backup:
du -h /mnt/zpaq-archives/zpaq-backup-of-etc1.zpaq
6.9M /mnt/zpaq-archives/zpaq-backup-of-etc1.zpaq
The index file:
du -h /root/zpaq-backup-of-etc-index.zpaq
36K /root/zpaq-backup-of-etc-index.zpaq
7. Now let's run the backup again - with the exact same command:
zpaq add /mnt/zpaq-archives/zpaq-backup-of-etc? /etc/ -index /root/zpaq-backup-of-etc-index.zpaq
zpaq v7.13 journaling archiver, compiled May 7 2016
/root/zpaq-backup-of-etc-index.zpaq: 1 versions, 854 files, 912 fragments, 0.036433 MB
Creating /mnt/zpaq-archives/zpaq-backup-of-etc2.zpaq at offset 0 + 7157508
Adding 0.000000 MB in 0 files -method 14 -threads 2 at 2016-06-23 07:57:36.
0 +added, 0 -removed.
0.000000 + (0.000000 -> 0.000000 -> 0.000104) = 0.000104 MB
0.022 seconds (all OK)
Only the index is kept locally.
8. Let's add a new file and try again:
touch /etc/goat1
zpaq add /mnt/zpaq-archives/zpaq-backup-of-etc? /etc/ -index /root/zpaq-backup-of-etc-index.zpaq
Output:
zpaq v7.13 journaling archiver, compiled May 7 2016
/root/zpaq-backup-of-etc-index.zpaq: 2 versions, 854 files, 912 fragments, 0.036537 MB
Creating /mnt/zpaq-archives/zpaq-backup-of-etc3.zpaq at offset 0 + 7157612
Adding 0.000000 MB in 1 files -method 14 -threads 2 at 2016-06-23 08:00:53.
+ /etc/goat1 0
# /etc/
2 +added, 0 -removed.
0.000000 + (0.000000 -> 0.000000 -> 0.000564) = 0.000564 MB
9. Now let's do the same thing, only this time we'll add a second file and delete the first file.
touch /etc/goat2
rm -f /etc/goat1
zpaq add /mnt/zpaq-archives/zpaq-backup-of-etc? /etc/ -index /root/zpaq-backup-of-etc-index.zpaq
Output:
zpaq v7.13 journaling archiver, compiled May 7 2016
/root/zpaq-backup-of-etc-index.zpaq: 3 versions, 856 files, 912 fragments, 0.037101 MB
Creating /mnt/zpaq-archives/zpaq-backup-of-etc4.zpaq at offset 0 + 7158176
Adding 0.000000 MB in 1 files -method 14 -threads 2 at 2016-06-23 08:06:10.
+ /etc/goat2 0
- /etc/goat1
# /etc/
2 +added, 1 -removed.
0.000000 + (0.000000 -> 0.000000 -> 0.000575) = 0.000575 MB
0.025 seconds (all OK)
As you can see ZPAQ understands that a file has been deleted.
10. Let's restore the full backup along with all of it's incrementals under a new directory called /lampros.
zpaq extract /mnt/zpaq-archives/zpaq-backup-of-etc? -to /lampros
Now let's see which one of the goat files is still there:
ls -al /lampros/etc/goat*
-rw-r--r-- 1 root root 0 Jun 23 08:06 /lampros/etc/goat2
Sources: