Postgresql 每天定时备份

前端之家收集整理的这篇文章主要介绍了Postgresql 每天定时备份前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

postgresql不提供这样的功能,所以根据操作系统的crontab配置文件

我的配置:

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/

# For details see man 4 crontabs

# Example of job definition:

# .---------------- minute (0 - 59)

# | .------------- hour (0 - 23)

# | | .---------- day of month (1 - 31)

# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...

# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

# | | | | |

# * * * * * command to be executed

30 10 * * * root /media/data/java/edu/backup.sh

backup.sh:

#!/bin/bash

echo "Starting Backup Postgresql ... "

su - postgres -c pg_dumpall > pgsql-backup.`date +%Y-%m-%d.%H:%M:%S`.dmp

tar zcvf /media/data/java/edu/pgsql-backup.`date +%Y-%m-%d`.tar.gz *.dmp

echo "Remove temp file ..."

rm -rf pgsql-backup.*.dmp

原文链接:https://www.f2er.com/postgresql/197059.html

猜你在找的Postgre SQL相关文章