I have a 4TB internal drive in my ubuntu server. This drive contains backups made by a script that's been running for years. This script creates a new directory every day and rotates the existing ones, something like backup.1 (today), backup.2 (yesterday), backup.3, and so on. It keeps 365 directories (so a full year of backups).
The script uses symlinks in order to not duplicate files. So backup.1 will contain new/changed files but files that are the same than yesterday will be symlinks to the files referenced in backup.2 (or point to the same inode if the one in backup.2 is a symlink). So this is very efficient.
The problem is I'm attaching an external drive now, another 4TB drive. I want to run a script to "clone" the internal 4TB directory using rsync. This is my script:
echo "Stopping crons"
/etc/init.d/cron stop
echo "Mounting external drive"
mount /dev/sdd1 /mnt/external-drive/
nice -n2 rsync -av --delete /mnt/master/ /mnt/external-drive/
echo "Starting CRONS"
/etc/init.d/cron start
The problem I have is my external drive is full. I check and rsync is not keeping the original structure. It's rather creating a new file even for the files that in the source drive are just links. My source drive has only 2TB used.