此脚本配合linux定时任务来打包文件,可以定时备份网站
直接上干货代码
#!/bin/bash #author : merci function web_backup(){ WEBPATH="/data/www" BACKPATH="/data/back" D=$(date +%Y%m%d) WEBLIST=`ls $WEBPATH` mkdir -p $BACKPATH/$D for webpack in $WEBLIST do tar -zcvPf $BACKPATH/$D/$webpack.tar.gz $WEBPATH/$webpack done } web_backup