I have two folders in my home directory that I need to backup to an external hard drive. Each folder has some files that should be excluded from the backup, and I have a file named "backup-exclude" in my home directory to specify these exclusions. Here is the directory structure:
Home Directory:
- Dir1/
- Dir2/
- backup-exclude
I want to use rsync to backup these folders to an external hard drive, and I would like to utilize hard links for unchanged files in order to save space. The external hard drive has the following structure:
External Hard Drive:
- Backup/
- backup-2023-06-10/
- Dir1/
- Dir2/
- backup-2023-06-03/
- Dir1/
- Dir2/
The file system format of the home directory is ext4, while the external hard drive is formatted as NTFS. The command I currently use to perform the backup is as follows:
rsync -av \
--exclude-from=backup-exclude \
--delete-excluded \
--delete-after \
~/Dir1 ~/Dir2 \
/external-hdd/Backup/backup-2023-06-10
However, I would like to modify this command to make use of hard links to previous backups on the external hard drive. I have attempted the following command, but it did not work as expected:
rsync -av \
--exclude-from=backup-exclude \
--delete-excluded \
--delete-after \
--link-dest=/external-hdd/Backup/backup-2023-06-03/ \
~/Dir1 ~/Dir2 \
/external-hdd/Backup/backup-2023-06-10
Can someone please provide the correct command to achieve the desired behavior of hard linking to previous backups on the external hard drive?