Saturday, July 25, 2009

rsync and screen

rsync is a file copying tool that has the ability to compare source and target directories and only copy differences.

The following is a script that copies data from one machine to another.

#!/bin/sh
SOURCE=source.site.no:/home/atle/file/dir
TARGET=/home/atle/download
KBPS=30
rsync -v -u -a --compress --delete --progress --bwlimit=$KBPS --rsh="ssh" $SOURCE $TARGET


The options I'm using is something I just copied from a backup-script. They work so I haven't spent time on it. The only thing I added was bwlimit to limit band with to 30 kilobyte per sec. This is because the source has limited band with on the up link.

screen
screen is a so called terminal multiplexer. It can run several terminals at once in one terminal, and switch between them. Also it is possible to detach from screen and leave it running as a background process, and later connect to it again.

What I use this for is:
Logging on to a remote machine from home.
Starting screen
Starting the rsync script
Press Ctrl-a d to detach from screen.
Log off

Later logging on to remote machine again
Start screen with -r option to reattach
Check download status, and if necessary restart the script to continue an interrupted download

No comments:

Post a Comment