first commit
This commit is contained in:
commit
ba848e218d
1001 changed files with 152333 additions and 0 deletions
34
数据库/postgresql/postgresql-base-update.sh
Normal file
34
数据库/postgresql/postgresql-base-update.sh
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Edit 2020/04/15
|
||||
|
||||
user=postgres
|
||||
source /home/$user/.bash_profile
|
||||
|
||||
backup=$PGDATA/../backup
|
||||
today=`date +%F`
|
||||
aweekago=`date -d -7days +%F`
|
||||
|
||||
host=10.1.139.126
|
||||
port=5432
|
||||
username=rep
|
||||
|
||||
if [ $UID -ne `id -u $user` ];then
|
||||
echo -e "\033[31;1mNot Manager of PostgreSQL! \033[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# create base backup
|
||||
echo -e "\033[33;1m---$today---\nBack up Now!\n---\033[0m"
|
||||
if [ -f "$backup/$today/base" ];then
|
||||
mkdir -p $backup/$today/base
|
||||
fi
|
||||
pg_basebackup -D $backup/$today/base -h $host -p $port -Ft -z -P -v -w -U $username
|
||||
echo -e "\033[33;1m---\n---Finish---\033[0m"
|
||||
|
||||
# switch wal
|
||||
psql postgres -c "checkpoint;"
|
||||
psql postgres -c "select pg_switch_wal();"
|
||||
|
||||
# clean backup 7 days ago
|
||||
rm -rf $backup/$aweekago
|
Loading…
Add table
Add a link
Reference in a new issue