Using Rsync to store Archive on external host

The Open Media Globe
Some external webhosts provide the option of adding smb mounts. Because the size of the MPEG2 files and the need to move them to the playback server, those files need to remain on a server on the same network as the playback server. The flash and thumbnails can be served externally. One way to serve both those needs is rsync.

The om_show module has an option to set an alternative directory for the flv and thumbnail. Using an rysnc command like...

rsync -avz --stats --exclude "*.mpg, *.mpeg, *.m2p" /mnt/[YOUR MOUNT]/archive /var/www/[PATH TO SITE]/files/archive_local

will create a local copy of directory structure of all the project directories in /archive along with the .flv and .jpg, but ignores the large MPEGs.

If the remote webhost does not provide the option of adding a smb mount but does provide ssh access you can set up the rsync command as follows:

On the local machine create a public/private key if you don't already have one:

ssh-keygen -t dsa

It will ask for a pass phrase but just hit enter.

Once you have the key pair. Copy the public key over to the remote host and add it to the authorized key file.

scp .ssh/id_dsa.pub remoteusername@remoterhost:

#login to the remote machine
ssh remoteusername@remotehost

#add the public key to the list of authorized keys
mkdir .ssh
cat id_dsa.pub >> .ssh/authorized_keys

#Return to the localhost
exit

Now use the following command to sync your files:

rsync -avz --stats --exclude "*.mpg, *.mpeg, *.m2p" /var/www/[PATH TO SITE]/files/archive_local/ remoteusername@remoterhost:/[PATH TO ARCHIVED FILES]/

The closing slashes matter. Don't leave them out.

Tips:

Use the -n option to rsync for testing. (-n means do a dry-run).
Read man rsync to learn what the other options do.
Remove the -v option and copy the command into your crontab. Run it every night at 3am.