如果我想在 Linux VPS 上压缩(或 tar.gz 压缩)路径列表(递归),然后将 ZIP/TAR 通过电子邮件发送给我自己,然后删除 ZIP/TAR,最简单的方法是什么?cron 作业、程序等上的 shell 脚本?
例如,这就是我可能会做的:
停止 apache、mysql、postgresql 和 rack
拉链拉上:
/etc/httpd/conf/httpd.conf
/etc/httpd/conf.d/*
/home/kerrick/*
/var/lib/mysql/*
# etc.
Run Code Online (Sandbox Code Playgroud)将 zip 文件作为附件通过电子邮件发送到 foobar@example.com
删除压缩文件
恢复 apache、mysql、postgresql 和 rack
您可以使用下一个脚本,当然更新您的信息:
#!/bin/sh
[ -f /etc/redhat-release ] && service httpd stop
[ -f /etc/debian_version ] && service apache2 stop
service mysqld stop
service postgresql stop
#Do the same for rack, not sure what the service is called.
zip -r /tmp/all_needed.zip /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/ /home/kerrick/ /var/lib/mysql/ # etc.
mail -s "test" yourmail@yourdomain.com < /tmp/all_needed.zip
rm -f /tmp/all_needed.zip
[ -f /etc/redhat-release ] && service httpd start
[ -f /etc/debian_version ] && service apache2 start
service mysqld start
service postgresql start
#Do the same for rack, not sure what the service is called.
Run Code Online (Sandbox Code Playgroud)
如果需要,让它作为 cron 运行。但确实会更好,例如 scp 或 ftp 而不是通过电子邮件发送,因为 zip 包可能太大并且无法作为附件发送。
| 归档时间: |
|
| 查看次数: |
187 次 |
| 最近记录: |