Вы находитесь на странице: 1из 2

Rsync link-dest - unsure if its creating hard

links
This is my first attempt at a shell script. I'm simply trying to make incremental copies
of certain folders from a server to another server using Rsync, but using the link-dest
option to create hardlinks to unmodified files. When I check the folder structure file
sizes as they exist in the folder 'Editshare_Backups' I see that they appear to be just as
large as each other. I am using du -sh * inside the 'Editshare_Backups' folder as I was
under the impression that du doesn't count a second hard link when calculating size.
I used stat -f %l on a specific file inside the first full backup and it shows only 1
hard link.
What other options are there for checking whether hard links have been made?
Code from my shell script is:
#!/opt/bin/bash
#Rsync Editshare Database Backups Script
#Todays date
TODAY=`date -I`

up vote 1
#Yesterdays date
down
PREVIOUS_DAY=`date -I`
vote
favorite #The source directory:
SRC1="/RAIDS/RAID_2"
SRC2="/etc"
SRC3="/var/lib"
#The target directory:
TRG="/volume1/Editshare_Backups/$TODAY"
#The link destination directory:
LNK="/volume1/Editshare_Backups/$PREVIOUS_DAY"
#The rsync options:
OPT="-avh -e ssh --delete --progress --link-dest=$LNK"
#Log file:
LOG="/volume1/Editshare_Backups/Logs/Log_$TODAY.log"
#Execute the backup
rsync $OPT root@192.168.1.248:$SRC1 :$SRC2 :$SRC3 $TRG >> $LOG 2>&1

rsync hard-link
shareimprove this question edited Jul 19 at 2:02 asked Jul 19 at 1:38

KM. C. Ricker
1,0711019 62
Your link-dest PREVIOUS_DAY is the same as TODAY, so no links can be made.
meuh Jul 19 at 9:15
aha! thankyou! Still finding after making this change though that du -sh * shows
the folders as being both large, i.e the second one hasnt copied only incremental
changes and hard linked to the first. The LOG though shows only 9GB was
transferred which makes me believe it did hard link? C. Ricker Jul 21 at 3:31
Looks like it should work, assuming the filesystem type allows hard links. I would
try copying the script and paring it down to backup a single small directory,
setting literally TODAY=today and PREVIOUS_DAY=yesterday. Run the script, then
mv today yesterday, and run again. On a separate point I can recommend
adding -R so that your backup tree represents exactly the source tree, eg rsync
-aR /a/b/c /x will create /x/a/b/c. This also avoids differences when the
source dir does or does not end in /. meuh Jul 21 at 7:16

Вам также может понравиться