Rsync better use for backup


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Rsync better use for backup
# 1  
Old 03-29-2013
Rsync better use for backup

Hello,

I have a list of working directory in a remote computer acesssible through ssh and the same directory structure in my home directory of my laptop. I sometimes work on both my laptop and my this other computer.

I usually use Rsync this way to synchronize files

Code:
rsync remotehost@remoteDirectory -auzv /local Directory 
rsync -auzv  /local Directory  remotehost@remoteDirectory

I run both of these as a shell script

This seems to work fine, but the problem that I face is that if I edit a file's nae in the local Host. or delete a file in the remote Host then when I execute these two commands, I get the old files + the new files in both places.

Thus before doing rsync, I would like to (say use ls and diff) to find out which files are not present in the Local Directory but present in the Remote Directory and which files vice versa.

Then I can check for those files, delete them or not, and then do these rsync commands.

If its possible to automate these things, with some better shell scripting than just simple rsync ?

also I want to know how useful is Crontab for these kinds of work. , or can I make Crontab run when both machines are on at a particular point of time in the day / week ?
# 2  
Old 03-29-2013
You can try using the rsync delete options, but you have to be very careful with these.
Code:
            --del                   an alias for --delete-during
            --delete                delete extraneous files from dest dirs
            --delete-before         receiver deletes before xfer, not during
            --delete-during         receiver deletes during the transfer
            --delete-delay          find deletions during, delete after
            --delete-after          receiver deletes after transfer, not during
            --delete-excluded       also delete excluded files from dest dirs

Find more options in man rsync
# 3  
Old 03-30-2013
Code:
also I want to know how useful is Crontab for these kinds of work. , or  can I make Crontab run when both machines are on at a particular point  of time in the day / week ?

crontab is obviously very useful, with two reservations.

Obviously, if the one of the machines is down, cron will not run. Smilie You could set up some mechanism to compensate for that (write a timestamp file, and check the file was created), but it would be a bother.

You could make the two machines run a job at the same time, but you would have to make sure the clocks are exactly the same. It's probably better to let one of them do it's think first, and then an hour or whatever later, let the other one. Or might be some way to do everything on one machine, and it runs a remote process on the other.
# 4  
Old 03-31-2013
Best would be a shell script of Rsyncs

Hello,

I was thinking of the Crontab stuff, but it looks a little messy, because one of the machines is my laptop , (which goes to sleep mode , or I shut it down) when I go out, and the other is the office computer.

1) Create a shell script of rsync commands.

So I guess in the situation , it would be best to
2) check filenames in both systems first, and see which files have got changed today at work. For this,

Combination of find with some options must work here I guess.!

ls -ltR would give the entire set of files ordered from time from oldest to recent.

3) Delete appropriate files in both systems which are extra ( like autosave files etc etc)

Here I think find could be useful . but it needs to be run on both machines

4) Then run a shell script of Rsync commands,

Any suggestions to improve this ??
# 5  
Old 04-02-2013
You're suggesting to maintain two separate working copies of a bunch of files, and keep them synced. I don't do that. So I'm reluctant to advise on this. If things didn't work correctly, it could be a big mess.

I always have just one working copy of everything, and I always access and work on that one copy. I think it's safer to just have one working copy. I back up that one copy in multiple ways to make sure it is not lost, and that I can retrieve a previous version if needed.

I think the only person who could advise you would be someone who keeps two working copies of everything, as you want to do.

Is there any chance you might just keep the files on the remote computer, and access them from your laptop?
# 6  
Old 05-06-2013
Backuo to third source ?

Hello,

If I have these two working copies that is because some days, I work on my laptop, and some days I work at the office computer.

I was thinking if it is possible to backup to a thrd source (like say an external HD), because today I am not able to access my office computer remotely over ssh.

so should I run it like this

Code:
#commands to backup into 3rd source
rsync -auzv "path in laptop" "pathin 3rd location"


#commands to backup from 3rd source to office computer, before I start working on the office computer.
rsync -auzv "path in 3rd location" "path in office comptuer"

#After the end of the day s work at the office computer., commands to backup into third source
rsync -auzv "path in office comptuer"  "path in 3rd location"

#and then backup to the laptop

rsync -auzv "path in 3rd location" "path in laptop"

I thiink I am complicating stuff here, but is there a simpler way out ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Backup solution using rsync

Hello All, I am looking at a fast way to script some backups. I am looking at using rsync to do the leg work. I am having a hard time conceiving a script though. I have a tree with subfolders within subfolders. I was looking at the /xd option to parse the tree. Directory of k:\ ... (4 Replies)
Discussion started by: jvamos
4 Replies

2. AIX

rsync backup root files

Hi, I am trying to use rsync utility through ssh to synchronize some root files of 2 servers. I have a rsyncusr user in each server. I configured ssh with no password. I set NOPASSWD in the /etc/sudoers file: rsyncusr ALL= NOPASSWD:/usr/bin/rsync In order to make rsync able to sudo and be... (2 Replies)
Discussion started by: samalogo
2 Replies

3. Shell Programming and Scripting

Rsync script and backup problems.

Hello everybody I'm triing since few days to do this. So sorry if my question looks stupide, but i've tried. I have to get picture from a folder (who is updated automaticly and with subfolder) with theirs extensions (i'm ok on that) and this files have to me copied in a folder where a website... (7 Replies)
Discussion started by: boytruc
7 Replies

4. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

5. Shell Programming and Scripting

rsync backup and recovery options

Hi, Do we have any options in rsync to recover files from the backup? Please share your thoughts. Thanks in advance. (0 Replies)
Discussion started by: MVEERA
0 Replies

6. UNIX Desktop Questions & Answers

Help with excluding .Trashes in an rsync backup

I'm using this script to backup an external hdd to another external hdd - rsync -aE --delete --exclude Volumes/Disk\ A/.Trashes "/Volumes/Disk A" "/Volumes/Disk A Backup"The source drive being "Disk A", and the drive I wish to backup to being "Disk A Backup". I'm constantly getting this error,... (4 Replies)
Discussion started by: Orbient
4 Replies

7. Shell Programming and Scripting

Rsync backup

How do i use Rsync yo pickup only new or modified files from source? I am using rsync -ravzpotu --delete-excluded but sometimes it goes thru all files again (5 Replies)
Discussion started by: sprool
5 Replies

8. Cybersecurity

Permissions for Backup user to rsync files

I've got a new MythTV box at home and figured it would be a great opportunity to use it to do daily mirrors of my mysqlbackup directory (let's say /mysqlbackup/backups) and my website at /usr/local/apache/htdocs and below. I figured it would be a best practice NOT to use a root login but to... (0 Replies)
Discussion started by: dheian
0 Replies

9. Shell Programming and Scripting

rsync script for synchronisation and backup

hello, i need to modified my synch/back scripts.... i want that this script only syncro folders in destinationfolder. f.e. when in destination are two folders 1) admin 2) users but in SOURCE are three: 1) admin 2) users 3) antivirus the script should only increnmential sync the... (0 Replies)
Discussion started by: onkeldave
0 Replies

10. Shell Programming and Scripting

Rotating snapshot backup using rsync

I want to take daily backup(11pm) of /var/www to /mnt/bak excluding /var/www/videos and /var/www/old. HOW to implement a rotating snapshot method, so that i can have multiple(say 4) automatically rotating backups. (0 Replies)
Discussion started by: proactiveaditya
0 Replies
Login or Register to Ask a Question