20 Jun
Shell script to remote uploading of backup files
In my old articles i explained how to create folder backup and Mysql database backup. Now I am sharing simple shell script to upload these backups to remote FTP server. Before running this script make sure FTP service installed or not on Linux box.
#Purpose = remote uploading of backup #Created on 18-06-2015 #Author = Rajeev Achra #Version 1.0 #!/bin/sh USERNAME="ftp-user-name" PASSWORD=" ftp-password" SERVER="ftp-server-name" # local directory to pickup *.tar.gz file FILE="local backup directory path without / in last" FILE_DATE="%Y%m%d" # remote server directory to upload backup BACKUPDIR="remote directory path" # login to remote server ftp -n -i $SERVER <<EOF user $USERNAME $PASSWORD cd $BACKUPDIR mput $FILE/*$FILE_DATE.tar.gz quit EOF
After uploading if you want to remove 5 days old backup files then simply you can use below command with shell script
find /path/to/files* -mtime +2 -exec rm {} \;
I am a software engineer who specializes in Internet applications. I have worked with a wide variety of technologies and programming languages to open source LAMP environments. I have more than 6 years of object-oriented programming experience and am highly proficient in ActionScript, PHP, MYSQL, JavaScript, Jquery and a multitude of other technologies used in modern web applications.
Follow me
Latest posts by Rajeev Achra (see all)
- Jquery webcam plugin - June 19, 2016
- How To Add and Delete Users on a CentOSServer - June 5, 2016
- How To Set Up vsftpd on CentOS 6 - June 5, 2016