Monday, January 14, 2008

Simple backups with (nc)FTP & ncftpput

Adding a little more from the previous ncFTP post, here is a little script that will copy all the contents of the directory defined on the 'BACKUP_DIR' variable to the FTP server defined by 'SERVER', on the server, the files are stored on the 'STORE_DIR' directory.
Since you are storing the password on the plain text file, set a permission on the script so that only root can see it:

chmod 0700 /usr/local/etc/scripts/backups/backup.ftp.sh


Here is the script:

#!/bin/sh

## /usr/local/etc/scripts/backups/backup.ftp.sh
## This script uses ncftp (& ncftpput) to copy files
## to the FTP server

BACKUP_DIR="/usr/local/share/backups/localhost/"
STORE_DIR="directory_name_on_the_server/"
FTP_COMMAND="/usr/local/bin/ncftpput"
USER="username.here"
PASSWD="password.here"
SERVER="ftp.server.URL.or.IP.address"

${FTP_COMMAND} -m -R -u ${USER} -p ${PASSWD} ${SERVER} ${STORE_DIR} ${BACKUP_DIR}

# EoF #

Labels: , , ,

0 Comments:

Post a Comment

<< Home