Since libguestfs 1.20 it has been possible to use rsync to upload or download files to a disk image incrementally. This is one way to do backups, but note that it won’t work on live guests unless you take a snapshot.
rsync involves using a network connection into or out of the appliance, and is therefore a lot more involved to set up. The script below shows one way to do this, by running an rsync daemon on the host, and letting the libguestfs appliance connect to it.
The script runs rsync inside the appliance, copying
/home from the attached disk image out to
/tmp/backup on the host. If the operation is repeated, then only incrementally changed files will be copied out. (To incrementally delete files on the target, add the
Note you will need to open port 2999 on your host’s firewall for this to work.
#!/bin/bash - set -x # The target directory. mkdir -p /tmp/backup # Create the daemon. rm -f /tmp/rsyncd.pid cat <<EOF > /tmp/rsyncd.conf port = 2999 pid file = /tmp/rsyncd.pid [backup] path = /tmp/backup use chroot = false read only = false EOF rsync --daemon --config=/tmp/rsyncd.conf # Run guestfish and attach to the guest. guestfish --ro --network -a /dev/fedora/f19rawhidex32 -i <<EOF trace on rsync-out /home rsync://email@example.com:2999/backup archive:true EOF # Kill the rsync daemon. kill `cat /tmp/rsyncd.pid`