We help IT Professionals succeed at work.

Unix FTP backup script with resume functions

lupadilha
lupadilha used Ask the Experts™
on
Hello,
I have a server running FreeBSD and a movie jukebox on unix. I need a script to copy folders from FreeBSD to the movie jukebox.

The script needs to check if the file already exists on the server, resume transfer (if possible) and do not overwrite any files, as it will be running on cron.

I've worked on something like this (based on some answers):

#!/bin/sh

ilockfile = /tmp/lockfile_for_backup_script
REMOTE='example.com'
PORT=20
USER='foob'
PASSWORD='mypassword'
FTPLOG='/var/mylog'

#check if lockfile exists, if it does, exit
if [ -e $lockfile ] ; then
   exit 0
fi

# ok lockfile doesnt exist, lets crate it
touch $lockfile

ftp -n $REMOTE $PORT <<_FTP>>$FTPLOG
quote USER $USER
quote PASS $PASSWORD
bin
cd /home/backups/
mput /home/file/bk*
quit
_FTP

# ok, we are done, remove lockfile
rm -f $lockfile

Open in new window


Basically it's a incremental backup script through FTP but this script does not support resume functions, it only overwrites everything. Can somebody help me out with my solution or provide another solution?

Thanks a lot, do not hesitate in asking further questions.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Assistant Vice President\Network Manager
Commented:
FTP

Overwrite/Resume options:

-O -- Overwrite if file exists
-OA -- Overwrite *all* if transfering a folder or directory of files.
-ON -- Overwrite files that are newer than existing files.
-OG -- Overwrite destination file if source file size is greater.
-OL -- Overwrite destination file if source file size is less (smaller).
-OS -- Skip file if exists
-R -- Resume if file exists
-RA -- Resume *all* files that exist.