Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My problem is, how can I make rsync to switch to another harddrive automatically if space on the first one is full? Is there a simple way? Or even a way without using rsync?

share|improve this question

1 Answer 1

I don't think what you propose is achievable (with just rsync) and/or sensible. Rsync synchronises objects in two locations. You should probably think about solving this on a lower level.

First of all, if this is how you back up your data, by splitting it randomly between two disks, you effectively double the chances of your backup becoming incomplete if one of the devices fail.

If you really don't care about that (depending on the data importance it might be a pretty bad idea), you could:

  1. remove partitions from both disks (I assume they're /dev/sdb and /dev/sdc)
  2. use Logical Volume Manager (LVM) to create a volume group using those disks as Physical Devices. It would have be roughly the size of a sum of sizes of both disks
  3. add a logical volume (or more) in this volume group
  4. create a filesystem on it
  5. mount it and use as the destination for your rsync copy.

in short (I named the Volume Group 'vg10' and the Logical Volume within it 'backup'):

dd if=/dev/zero of=/dev/sdb bs=512k count=1
dd if=/dev/zero of=/dev/sdc bs=512k count=1
vgcreate vg10 /dev/sdb /dev/sdc
vgdisplay vg10 # look for number of free physical extents
lvcreate vg10 -n backup -l<number_of_free_physical_extents>
mkfs.xfs -L backup /dev/vg10/backup
mkdir /mnt/backup
echo "/dev/vg10/backup /mnt/backup xfs defaults 0 0" >> /etc/fstab
mount -a

Keep in mind that you'll need both disks connected to be able to mount /mnt/backup and that this doesn't give you ANY redundancy.

I don't know your scenario but I'd go with at least a RAID1 setup for my backup.

share|improve this answer

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.