Server Scripting - FTP Backup over the Intarweb
15:05.31 - Sunday 12th June 2005 (Link to This Entry)
After the router died on me the other week, I had some configuring to do in order to get the Linkstation FTP up and running again. I sorted this without problems, but it started me thinking about server backups which I don't do anywhere near as often as I should.
Playing around with the Linux shell on the server, I found a fairly easy way to zip up all of the MySQL tables and transfer them over the internet to my Linkstation at home. All that is required is a net connection and a copy of PuTTy and I can fire off the script with ease:
- #!/bin/sh
# create the zip file in the root folder
zip >backup-output.txt -r backup.zip /var/lib/mysql/
# create a list of inputs to feed back into the FTP prog
echo "dude" > backup-input.txt
date +"put backup.zip /backup/%Y%m%d-%H%M.zip" >> backup-input.txt
echo "quit" >> backup-input.txt
# call teh FTP program, feeding it the inputs
ftp 111.222.33.44 < backup-input.txt
# signal done
rm backup-output.txt
rm backup-input.txt
rm backup.zip
echo ">>>>> DONE <<<<<"
