备份网站内容的shell脚本代码
程序员文章站
2023-11-19 14:36:22
备份网站内容 复制代码 代码如下:#!/bin/bash#指定运行的脚本shell#运行脚本要给用户执行权限bakdir=/backupmonth=`date +%m`da...
备份网站内容
#!/bin/bash
#指定运行的脚本shell
#运行脚本要给用户执行权限
bakdir=/backup
month=`date +%m`
day=`date +%d`
year=`date +%y`
hour=`date +%k`
min=`date +%m`
dirname=$year-$month-$day-$hour-$min
mkdir $bakdir/$dirname
mkdir $bakdir/$dirname/conf
mkdir $bakdir/$dirname/web
mkdir $bakdir/$dirname/db
#备份conf,检测通过
gzupload=upload.tgz
cp /opt/apache2/conf/httpd.conf $bakdir/$dirname/conf/httpd.conf
cd /opt/apache2/htdocs/php
tar -zcvf $bakdir/$dirname/web/$gzupload ./upload
#远程拷贝的目录要有可写权限
scp -r /backup/$dirname root@10.1.1.178:/backup
复制代码 代码如下:
#!/bin/bash
#指定运行的脚本shell
#运行脚本要给用户执行权限
bakdir=/backup
month=`date +%m`
day=`date +%d`
year=`date +%y`
hour=`date +%k`
min=`date +%m`
dirname=$year-$month-$day-$hour-$min
mkdir $bakdir/$dirname
mkdir $bakdir/$dirname/conf
mkdir $bakdir/$dirname/web
mkdir $bakdir/$dirname/db
#备份conf,检测通过
gzupload=upload.tgz
cp /opt/apache2/conf/httpd.conf $bakdir/$dirname/conf/httpd.conf
cd /opt/apache2/htdocs/php
tar -zcvf $bakdir/$dirname/web/$gzupload ./upload
#远程拷贝的目录要有可写权限
scp -r /backup/$dirname root@10.1.1.178:/backup
上一篇: SEO优化和竞价哪个职业前景更好?
下一篇: 搜狗壁纸默认分类太少如何添加格子