Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a dedicated ubuntu server with hetzner.de. hetzner also provides a seperate backup space accessible via samba/ftp/sftp/scp.

In their support document about backups, the following line is mentioned.

"The direct use of rsync is not possible. The backup space can however be locally mounted using smbfs, sshfs or ftpfs, allowing a limited use of rsync. To take full advantage of rsync (such as incremental backups using hardlinks) an image file must be created, which should be mounted via loopback."

I would like to use rsync with incremental backups using hardlinks. I think by loopback they mean http://en.wikipedia.org/wiki/Loop_device. can any one help on how I can create a image from the network location.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted
  1. Mount your network location with whichever protocol you're using:

    # smbfs example:
    mount -o username=your_hetzner_username //server.or.ip.addr/sharename /mnt/server-mountpoint
    
  2. Create an ext2fs image (or another filesystem, if you prefer) inside a file on that share. Do this only the first time, as it wipes the data in backup-fs.image:

    # create a 1000 MB file for the backup disk image (you will need to choose a size that works for you)
    dd if=/dev/zero of=/mnt/server-mountpoint/backup-fs.image bs=1048076 count=1000 
    
    # create an ext2 filesystem inside the image
    mke2fs /mnt/server-mountpoint/backup-fs.image
    
  3. Mount the newly-created image with as a loopback device.

    mount -o loop /mnt/server-mountpoint/backup-fs.image /mnt/backup-mountpoint/
    

When you're done using it, you can umount /mnt/backup-mountpoint and umount /mnt/server-mountpoint, and then to update your backup later, repeat steps 1 and 3.

The Wikipedia page you linked is the correct topic, but the actual loopback device process is simpler than they make it seem. Dealing with the server mount is more complicated, and may require some experimentation. There are a number of other questions on this site for dealing with each of the above steps, in case you get stuck.

share|improve this answer
    
Thanks this answer helped. Though for some reason dd wouldn't terminate when I increased the count to compensate for the 100GB backup hetzner provides like this. dd if=/dev/zero of=/home/hetzner_bk/backup-fs.image bs=1048076 count=90000 so I used something like to see dd with a progress bar. sudo dd if=/dev/zero bs=2048 | pv -s 99G | sudo dd bs=2048 of=/mnt/server-mountpoint/backup-fs.image This also wouldn't end after the 99GB, so when the progress bar hit close to 99G, I had to find the pid for dd process, and send kill -15 $pid to abort it. Finally everything worked. –  vinos Aug 15 '12 at 21:31
add comment

This should be a comment to mrb's answer. But I am not allowed to add comments, so adding this as another answer.

We can use the following dd command for the 100GB image creation to save some time.

dd if=/dev/zero of=/mnt/hetzner_backup/backup-fs.image bs=1024 count=0 seek=$[1024*1024*100]

This finishes in a fraction of a second, while the one in mrb's answer takes forever. Moreover, vinos seemed to have problems with the dd command not finishing.

Reference: http://www.cyberciti.biz/faq/howto-create-lage-files-with-dd-command/

It may also be worth noting that when formatting these images with mke2fs, we should answer yes to the question it asks whether we want to continue formatting a non-block-special-device.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.