Linux备份

来自Org
跳转至: 导航搜索

您当前所在的位置:首页 > 架设手册 > Linux备份
  1. 各个Linux服务器的备份文件都是/root/backup.sh,每天凌晨3-5点钟自动运行;
  2. 各个服务器的备份内容主要是网站根目录,/etc配置文件夹以及mysqldump产生的数据库备份文件;
  3. 备份文件生成好了之后自动上传到185备份服务器上面,要定期清理上面的空间;(后改为cp到mount的专门备份磁盘中)
  4. Linux下面生成的备份文件会根据backup.sh里面设置的天数自动清理掉,也要清理检查;
  5. 要修改备份文件的设置,修改/root/backup.sh脚本文件就行了。

备份脚本例子:

#!/bin/sh
DATE=`date +%Y-%m-%d-%H`

echo 'make taring ... please wait ....'
cd /backup
tar -zcf web184-apache.$DATE.tar.gz --exclude='images/cache/*' /usr/local/apache2/htdocs
tar -zcf web184-etc.$DATE.tar.gz /etc/ /usr/local/apache2/conf/
#ping -c 3 221.233.134.185 > /dev/null

#if [ $? == 0 ]; then
#ftp -n -i 221.233.134.185 <<!
#user backup #]'/[;.pl,#
#bin
#cd 139
#put web184-apache.$DATE.tar.gz
#put web184-etc.$DATE.tar.gz 
#bye
#!
#echo 'files uploaded successfully.' >> /root/del.backup.log
#else echo 'the ftp server looks break down.' >> /root/del.backup.log
#fi
cp web184-apache.$DATE.tar.gz /mnt/nfs
cp web184-etc.$DATE.tar.gz /mnt/nfs
###############################################################################
# del the old backup files ...
find /backup/ -maxdepth 1 -name 'web184*.tar.gz' -type f -ctime +7 -exec rm -vf {} \; >> /root/del.backup.log 2>&1;
find /mnt/nfs/ -maxdepth 1 -name 'web184*.tar.gz' -type f -ctime +7 -exec rm -vf {} \; >> /root/del.backup.log 2>&1;

或者:

DATE=`date +%Y-%m-%d-%H`
#cd /usr/local/bin
find /backup/ -maxdepth 1 -type f -ctime +0 -exec rm -vf {} >> /root/del.backup.log 2>&1 \;
mysqldump -uroot -ppassword information_schema > /backup/information_schema$DATE.sql
### mysqldump -uroot -ppassword 2008 > /backup/2008$DATE.sql
### mysqldump -uroot -ppassword army > /backup/army$DATE.sql
### mysqldump -uroot -ppassword baby > /backup/baby$DATE.sql
### mysqldump -uroot -ppassword beijing2008 > /backup/beijing2008$DATE.sql
### mysqldump -uroot -ppassword biology > /backup/biology$DATE.sql
### mysqldump -uroot -ppassword chemistry > /backup/chemistry$DATE.sql
### mysqldump -uroot -ppassword chinese > /backup/chinese$DATE.sql
mysqldump -uroot -ppassword cn18daocom > /backup/cn18daocom$DATE.sql
mysqldump -uroot -ppassword cn18daonet > /backup/cn18daonet$DATE.sql
### mysqldump -uroot -ppassword en18daocom > /backup/en18daocom$DATE.sql
mysqldump -uroot -ppassword en18daonet > /backup/en18daonet$DATE.sql
### mysqldump -uroot -ppassword english > /backup/english$DATE.sql
### mysqldump -uroot -ppassword film > /backup/film$DATE.sql
 mysqldump -uroot -ppassword adsensebook > /backup/adsensebook$DATE.sql
### mysqldump -uroot -ppassword football > /backup/football$DATE.sql
### mysqldump -uroot -ppassword games > /backup/games$DATE.sql
### mysqldump -uroot -ppassword geography > /backup/geography$DATE.sql
### mysqldump -uroot -ppassword google > /backup/google$DATE.sql
### mysqldump -uroot -ppassword hardware > /backup/hardware$DATE.sql
### mysqldump -uroot -ppassword history > /backup/history$DATE.sql
mysqldump -uroot -ppassword jamesqi > /backup/jamesqi$DATE.sql
### mysqldump -uroot -ppassword lady > /backup/lady$DATE.sql
mysqldump -uroot -ppassword test18daoorg > /backup/test18daoorg$DATE.sql
### mysqldump -uroot -ppassword music > /backup/music$DATE.sql
mysqldump -uroot -ppassword mysql > /backup/mysql$DATE.sql
mysqldump -uroot -ppassword note > /backup/note$DATE.sql
mysqldump -uroot -ppassword postcode > /backup/postcode$DATE.sql
### mysqldump -uroot -ppassword star > /backup/star$DATE.sql
mysqldump -uroot -ppassword telecode > /backup/telecode$DATE.sql
mysqldump -uroot -ppassword tw18daonet > /backup/tw18daonet$DATE.sql
###mysqldump -uroot -ppassword wiki027cn > /backup/wiki027cn$DATE.sql
mysqldump -uroot -ppassword wiki18daocom > /backup/wiki18daocom$DATE.sql
###mysqldump -uroot -ppassword wiki18daocom-new > /backup/wiki18daocom-new$DATE.sql
mysqldump -uroot -ppassword www18daoorg > /backup/www18daoorg$DATE.sql
mysqldump -uroot -ppassword ipshu > /backup/ipshu$DATE.sql
mysqldump -uroot -ppassword wenbanzhu > /backup/wenbanzhu$DATE.sql
###mysqldump -uroot -ppassword cn18daonet-new > /backup/cn18daonet-new$DATE.sql
###mysqldump -uroot -ppassword en18daonet-new > /backup/en18daonet-new$DATE.sql
mysqldump -uroot -ppassword www027cn > /backup/www027cn$DATE.sql
cd /backup
tar -czf mysql-db.$DATE.tar.gz *$DATE.sql
tar -Pczf mysql-etc.$DATE.tar.gz /etc/ /usr/local/apache2/conf/

#ping -c 3 221.233.134.185 > /dev/null

#if [ $? == 0 ] ; then
#ftp -n -i 221.233.134.185 <<!
#user backup #]'/[;.pl,#
#bin
#cd 133
#put mysql-db.$DATE.tar.gz
#put mysql-etc.$DATE.tar.gz
#bye
#!
#echo 'file uploaded seccussfully.' >> /root/del.backup.log
#else echo 'the ftp server is break down.' >> /root/del.backup.log
#fi
cp mysql-db.$DATE.tar.gz /mnt/nfs
cp mysql-etc.$DATE.tar.gz /mnt/nfs
###############################################################################
# del old backup files ...
#find /backup/ -maxdepth 1 -type f -ctime +0 -exec rm -vf {} >> /root/del.backup.log 2>&1 \;
find /mnt/nfs/ -maxdepth 1 -name '*.tar.gz' -type f -ctime +6 -exec rm -vf {} >> /root/del.backup.log 2>&1 \;
###############################################################################

关于“Linux备份”的留言:

目前暂无留言

新增相关留言