You are not logged in.

#1 2012-02-03 09:52:55

dkremer
Member
Registered: 2011-08-10
Posts: 15

Selective backup with cron [SOLVED]

Hello,

I use archlinux on a small external 2.5" HDD which I plug into the USB system before to switch on my computer.

By this way, I can boot the same operating system on different computers, always having my /home directory and my favorite desktop environment at hand.

I also need to make backup, but the way to backup my files can be different if I am on my computer at home or at my computer at work. Indeed, at work, I can backup my files through SSH and also to an internal HDD inside of the computer I am using. At home, I have only a LVM partition to backup my most precious data.

In the past, I used a cron job to make a hourly backup of my work, but now I need this job to resolve between different configurations. How one can guess the existence or not of a backup media, then to adapt the backup procedure to the situation ?

I can think of one obvious way. In the backup script (let it be 'backup.sh'), one can test for the UUID of the available devices identified as destination devices for the backup, and then proceed to the backup if one of this devices is up and running. This raises the question of the ssh host, because as far I know it has not an UUID, just a hostname which I could ping to see if the host is available.

Can anyone make a suggestion and report me if this is a good design in general ? I thought of something more complicated such as the use of UDEV to detect external devices, but it could be too complicated and costly, and also a waste to learn the UDEV language additionnally to the bash language that I already know a bit if the latter could give me an good solution.

I really thank you very much.

Here is my script if someone could be interested in reading it : http://paste.pocoo.org/show/545061/

Last edited by dkremer (2012-02-03 13:13:13)

Offline

#2 2012-02-03 11:10:43

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: Selective backup with cron [SOLVED]

I haven't read your backup script.  I use the existence of uniquely named files to determine where backups are written.

On each backup partition, create a file with a unique name and test for the existence of that file in your script.  A quick (poorly written) example using if..else:

if [[ -f "/backup/.pc1_lock" ]]; then
    ...    ## Set backup media 1 here.
else
    ...    ## Set backup media 2 here.
fi

Last edited by thisoldman (2012-02-03 11:10:59)

Offline

#3 2012-02-03 13:12:57

dkremer
Member
Registered: 2011-08-10
Posts: 15

Re: Selective backup with cron [SOLVED]

Thanks a lot.

Your opinion is very valuable.

This way answers totally my need. That is really nice and great from you.

Cheer, and faithfully yours.

David

Offline

Board footer

Powered by FluxBB