备份网站程序
#!/bin/bash /bin/tar czf /mnt/backup_website/web_$(date +%Y%m%d_%H%M%S).gz.tar /mnt/wwwroot/web cd /mnt/backup_website find . -mtime +1 -name "*20[1-9][3-9]*" | xargs rm -f exit 0
备份数据库
#!/bin/bash /bin/tar czf /mnt/backup_website/newjiagu_$(date +%Y%m%d_%H%M%S).gz.tar /mnt/wwwroot/newjiagu cd /mnt/backup_website find . -mtime +1 -name "*20[1-9][3-9]*" | xargs rm -f exit 0 [[email protected] shell]# cat backup_database.sh #!/bin/bash mysqldump -uroot -proot web > /home/database/web_$(date +%Y%m%d_%H%M%S).sql cd /home/database find . -mtime +7 -name "*20[1-9][3-9]*" | xargs rm -f exit 0
切割日志
#!/bin/bash LOGS_PATH=/home/wwwlogs YESTERDAY=$(date -d "yesterday" +%Y%m%d) mv ${LOGS_PATH}/access.log ${LOGS_PATH}/${YESTERDAY}.log kill -USR1 `ps axu | grep "nginx: master process" | grep -v grep | awk ‘{print $2}‘` cd ${LOGS_PATH} find . -mtime +7 -name "*20[1-9][3-9]*" | xargs rm -f exit 0
时间: 2024-10-13 22:31:31