Monday, January 14, 2013

Using rsync to keep my media files current.

All,

I've been using rsync to keep my media folder current between my server and an external drive. The server is an ext4 partition and the remote drive is formatted as NTFS for compatibility reasons.

I've written a little bash script to make this fool proof. One option to sync to my media server and one option to sync to my desktop where the external drive gets mounted.

The media server is mounted via CIFS to my workstation as /storage/media/Movies

The external drive is mounted NTFS-3g as /external/Movies

#! /bin/bash
PS3='Please enter your choice: '
options=("Sync to Server" "Sync to Desktop"  "Quit")
select opt in "${options[@]}"
do
    case $opt in
        "Sync to Server")
            echo "you chose Sync to Server";
            rsync -rltDvu --modify-window=1 --progress /external/Movies/ /storage/media/Movies/;
            break;
            ;;
        "Sync to Desktop")
            echo "you chose Sync to Desktop";
            rsync -rltDvu --modify-window=1 --progress /storage/media/Movies/ /external/Movies/;
            break;
            ;;
        "Quit")
            break
            ;;
        *) echo invalid option;;
    esac
done


This script give me 2 options. 1 Syncs from the external drive to my server and 2 syncs from the server to the external drive.

I'm no bash wizard but if this helps you great!

1 comment:

  1. Very good article on rsync. Here is one from around 1999 but still the very best rsync tutorial I've ever read. Explains it very well IMO: http://tinyurl.com/l37guv8

    ReplyDelete