1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#!/bin/sh cd /root #dump the DB /usr/local/bin/mysqldump --opt --user=hxs --password=****** --host=localhost hxs > hxs.sql /usr/local/bin/mysqldump --opt --user=hxs --password=****** --host=localhost blog > blog.sql #tar the file tar -zcvf hxs.sql.tar.gz hxs.sql tar -zcvf blog.sql.tar.gz blog.sql tar -zcvf hxs.tar.gz /usr/local/www/apache24/data/hxs tar -zcvf blog.tar.gz /usr/local/www/apache24/data/blog #upload to the FTP ftp -v -n dedibackup-dc2.online.net << EOF user sd-66666 ****** type binary cd /backup put hxs.sql.tar.gz put hxs.tar.gz put blog.sql.tar.gz put blog.tar.gz bye EOF #del the local file rm -rf /root/*.tar.gz rm -rf /root/*.sql |
save the code below as backup.sh under the /root
run:
1 |
chmod +x /root/backup.sh |
run:
1 |
crontab –e |
add:
1 |
00 05 * * * /root/backup.sh |
未经允许不得转载:VPS啦 » How to backup you data to remote FTP server daily