0

Shell script to backup a directory and transmit it via FTP

If you want a Shell script to backup a MySQL database and transmit it via FTP, checkout my other post here.

As any good system admin knows, it is important to have up to date backups of things. In order to backup and store the directory containing an entire website on a remote Linux server I came up with the following shell script which archives a directory, then connects to a remote FTP server and transmits the archive. It then deletes the archive from the remote system. Just remember to fill in the blanks with your own information or it wont work:


You can run this manually but I’d suggest running it via a CRON job at a set interval.
I use this command to run it at quarter past 4 every morning:

15 4 * * * /backup/scripts/fileBackup.sh

You can use

crontab -l

to list all cron jobs or

crontab -u username -l

to list all cron jobs for a particular user

Click here if you want a shell script that can be used to dump a MySQL database and transfer the resulting .sql file to a remote FTP server.

Subscribe to my feed either by E-mail or by RSS to receive updates as they happen.
Can you improve on any of the tips I’ve discussed here? If you can let me know in the comments.

Jason Edwards