Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Backup file from ftp server using wget.
- BACKUP=/tmp/backup
- LOG=/tmp/wget-log.$$
- NOW=$(date +"%Y-%m-%d")
- # FTP server conf
- FTPD="your-ftp-directory"
- FTPU="your-ftp-user"
- FTPP="your-ftp-password"
- FTPS="your-ftp-server"
- WGET="$(which wget)"
- # Other stuff
- EMAILID="xxxx@xxxx.com"
- # Start Backup for file system
- [ ! -d $BACKUP ] && mkdir -p $BACKUP || :
- [ ! -d $BACKUP/$NOW ] && mkdir -p $BACKUP/$NOW || :
- # Get backup using wget
- $WGET --mirror -o $LOG --no-host-directories --directory-prefix=$BACKUP/$NOW \
- --no-verbose --tries=5 --user=$FTPU --password=$FTPP $FTPS/$FTPD
- # Find out if ftp backup failed or not
- if [ $? -eq 0 ]; then
- echo "Backup success">>$LOG
- tail $LOG | mail -s "BACKUP SUCCESS" "$EMAILID"
- rm -f $LOG
- else
- echo "Date: $(date)">>$LOG
- echo "Hostname: $(hostname)" >>$LOG
- echo "Backup failed" >>$LOG
- tail $LOG | mail -s "BACKUP FAILED" "$EMAILID"
- fi
- # Remove backup older than two weeks.
- find $BACKUPD -maxdepth 1 -type d -daystart -ctime +2 -exec rm -rf {} \;
Add Comment
Please, Sign In to add comment