rsync home to new partition
Donn
donn.ingle at gmail.com
Wed Nov 19 08:08:58 UTC 2008
On Wednesday, 19 November 2008 00:56:42 list at loampitsfarm.co.uk wrote:
> Now before I foul up again I'd like a bit of help with the command
> line to rsync the user files from the old home directory to the
Here's a script I use all the time. Be sure to read it and change to your
needs:
---
#!/bin/bash
#First backup location - external drive
# ZZZ is the final directory where backups will go
T2=/media/XXX/YYY/ZZZ
[ ! -d "$T2" ] && echo "$T2 not available" && exit 1
#Your home directory
S=/home/XXX
echo "backup start :" `date` > $S/report
## SUPER NB:
##A trailing slash on the source means dirs will
##be correct on target!
s[1]=$S/SOMEDIR1/
t[1]=SOMEDIR1_backup
s[2]=$S/SOMEDIR2/
t[2]=SOMEDIR2_backup
etc..
#Get the number of targets:
len=${#t[@]}
#Start a loop to rsync them all.
i=1
while [ "$i" -le "$len" ]
do
SS=${s[$i]}
TARGET=$T2/${t[$i]}
# This line will keep an exact clone on the target - deleting what's not in
# the source tree (--delete).
rsync -vurtl --safe-links --delete "$SS" "$TARGET" >> $S/rsync.out
((i=i+1))
done
#Finish report and email to me:
echo "backup end :" `date` >> $S/report
cat $S/report | mail -s "backup report" YOU at localhost
---
(There may be a bug or two as I edited it in this email a little...)
Save it some place, edit it, chmod u+x it and put it on a cron.
HTH,
\d
--
"A computer without Windows is like chocolate cake without mustard."
-- Anonymous Coward /.
Fonty Python and other dev news at:
http://otherwiseingle.blogspot.com/
More information about the kubuntu-users
mailing list