pg数据库
默认使用pg_dump,命令行会提示输入密码,编写这个文件:/root/.pgpass,内容如下:
hostname:port:database:username:password
权限修改为0600
再编写备份脚本:
#!/bin/sh
time=`date "+%Y%m%d%H%M%S"`
war_home=/opt/apache-tomcat-7.0.65/webapps
#stop tomcat
echo 停止tomcat
service tomcat stop
# 备份数据库
pg_dump -h localhost --file pgdata/${time}.sql -U admin database_prod
如果是tar备份多个目录,写法:
tar -czf /root/wx_res.tar.gz mb mch news uploads