Example code snippets:
# Variables
HOST=remote.host.tld
USERNAME=remoteuser
PORT=22
SSH_CIPHER="blowfish"
SSH_KEY="/home/localuser/.ssh/id_dsa"
# define the array of folders to backup
declare -a sourcedir=( "/etc" "/usr/local" "/opt/data/Users/" )
# I usually define the backup job as a function, then call it if
certain conditions exist, like being able to ping the remote host
RsyncRun ()
{
for (( i = 0 ; i < $elements ; i++ ))
do
rsync -t -ruz --progress --delete --inplace --rsh="ssh -c
$SSH_CIPHER -p $PORT -i $SSH_KEY" ${sourcedir[$i]} $USERNAME
done
}
# example network checking function
CheckNet ()
{
# Original network test was ICMP based. In locations that prohibit
ICMP we are using scp instead.
#ping -c 1 $HOST >& /dev/null ;
scp -c $SSH_CIPHER -i $SSH_KEY $PendingUpDir/null.bin $HOST:$REMOTE_PATH/
}
# Then you could do something like this
if CheckNet ; then
RsyncRun
exit 0
else
echo "### Your internet connection is probably unwell, cannot backup. ###"
exit 1
fi
On Tue, Jul 26, 2011 at 11:38 PM, Gustin Johnson <[email protected]> wrote:
> How I do it is to define an array of paths that I want to backup, then
> iterate over them. I will send some example code when I am next near an
> actual computer (I only have my phone tonight).
>
> Sent from my Android device. Please excuse my brevity.
>
> On Jul 26, 2011 8:49 PM, "Joe S" <[email protected]> wrote:
>> I am using ext3 for a filesystem. I used 'du -hs' to calculate
>> the disk usage. Each of the backups: backup.1 through backup.7
>> are each 12G, but squeeze shows 17G. From from what I understand
>> with the 'link-dest=DIR' option I have backup.0 linked to
>> backup.1, so only changed or new files should copied over to
>> backup.0 and the rest should be hard linked to backup.1. /etc,
>> /root /boot /usr/local only take 50M and the files in /home/joe
>> that I backup don't change much. I don't have any files in there
>> that I have hard linked. I used this article to learn about the
>> link-dest=DIR
>> http://blog.interlinked.org/tutorials/rsync_time_machine.html
>>
>> I didn't have trouble with incremental backups when I just backed
>> up /home, but adding other directories: /etc/ /usr/local/ /root
>> and /boot has changed things.
>>
>> On Monday 25 July 2011 11:52:07 pm Mark Carlson wrote:
>>> What filesystem and how many files do you have? Millions of
>>> hardlinks repeated 8 times would take up quite a bit of
>>> space.
>>>
>>> Alternately, there may just be 5GB worth of changes made to
>>> files. Are you backing up any databases? Large compressed log
>>> files? Web browser cache? Software updates?
>>>
>>> I suppose the tool that is calculating disk usage may not be
>>> handling hard links in a useful way. How are you calculating
>>> the disk usage exactly? Are backup.1 through backup.7 all the
>>> same size or do they vary quite a bit?
>>>
>>> -Mark C.
>>>
>>> On Mon, Jul 25, 2011 at 7:27 PM, Joe S <[email protected]> wrote:
>>> > I have a question for someone with experience with rsync
>>> > backups.
>>> >
>>> > I am using rsync for incremental backups. I am backing up
>>> > from one hard drive to another: backing up directories
>>> > under / on one hard drive to /mnt/backup/squeeze/backup.0
>>> > on the second hard drive. On the second hard drive I am
>>> > using rsync with the hard link option (link-dest=) to link
>>> > backup.0 to the previous backup (backup.1).
>>> >
>>> > I checked the amount of space used on the backups on
>>> > /mnt/backup/squeeze/
>>> > Each backup from backup.0 to backup.7 under squeeze is 12G.
>>> > The total for squeeze is 17G. All the backups are hard
>>> > linked and I am not making much for changes. Why am I
>>> > adding 5G?
>>> >
>>> > Thanks
>>> >
>>> > Backup Script
>>> > #!/bin/bash
>>> > mount /mnt/backup
>>> > cd /mnt/backup/squeeze/
>>> > rm -rf backup.7
>>> > mv backup.6 backup.7
>>> > mv backup.5 backup.6
>>> > mv backup.4 backup.5
>>> > mv backup.3 backup.4
>>> > mv backup.2 backup.3
>>> > mv backup.1 backup.2
>>> > mv backup.0 backup.1
>>> > cd /
>>> > rsync -am --delete-after --filter="merge
>>> > /root/scripts/filter- rule" --delete-excluded \
>>> > --link-dest=/mnt/backup/squeeze/backup.1 \
>>> > / /mnt/backup/squeeze/backup.0
>>> > umount /mnt/backup
>>> >
>>> >
>>> > Filter rule:
>>> > - /home/joe/downloads/
>>> > - /home/joe/.local/share/Trash/
>>> > + /home/
>>> > + /etc/
>>> > + /root/
>>> > + /boot/
>>> > + /usr/
>>> > + /usr/local/
>>> > - /usr/*
>>> > - /*
>>> >
>>> > _______________________________________________
>>> > clug-talk mailing list
>>> > [email protected]
>>> > http://clug.ca/mailman/listinfo/clug-talk_clug.ca
>>> > Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
>>> > **Please remove these lines when replying
>>>
>>> _______________________________________________
>>> clug-talk mailing list
>>> [email protected]
>>> http://clug.ca/mailman/listinfo/clug-talk_clug.ca
>>> Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
>>> **Please remove these lines when replying
>>
>> _______________________________________________
>> clug-talk mailing list
>> [email protected]
>> http://clug.ca/mailman/listinfo/clug-talk_clug.ca
>> Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
>> **Please remove these lines when replying
>
_______________________________________________
clug-talk mailing list
[email protected]
http://clug.ca/mailman/listinfo/clug-talk_clug.ca
Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
**Please remove these lines when replying