first commit
This commit is contained in:
commit
ba848e218d
1001 changed files with 152333 additions and 0 deletions
27
数据库/postgresql/postgres-backup.sh
Normal file
27
数据库/postgresql/postgres-backup.sh
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Edit 2020/4/10
|
||||
|
||||
backup=$PGDATA/../backup
|
||||
now=`date +%Y%m%d-%H%M%S`
|
||||
aweekago=`date -d -7days +%Y%m%d`
|
||||
|
||||
host=10.1.139.126
|
||||
port=5432
|
||||
username=yanzhao
|
||||
database=yzdb
|
||||
|
||||
if [ $UID -eq 0 ];then
|
||||
echo -e "\033[31m;1mDo not Use Root! \033[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ~/.bash_profile
|
||||
|
||||
if [ ! -f $backup ];then
|
||||
mkdir -p $backup
|
||||
fi
|
||||
|
||||
pg_dump -h $host -p $port -U $username --no-password -d $database -F c -b -v -f $backup/$database-$now.bak
|
||||
|
||||
cd $backup && tar zcvf $database-$aweekago.tar.gz $database-$aweekago-* --remove-files
|
Loading…
Add table
Add a link
Reference in a new issue