Last active
July 17, 2020 20:06
-
-
Save lucassmacedo/57b0d0be43e8984a36f76a07362914c7 to your computer and use it in GitHub Desktop.
Database Backup & Restore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bookstack | |
mysqldump -u root bookstack > /bkp/mysql/mysql-`hostname`-`date +%Y-%m-%d-`bookstack.sql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
find /bkp/postgres/ -mtime +2 -exec rm {} \; | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################## | |
#!/bin/bash | |
dt=$(date) | |
#data=$(cat /etc/bacula/scripts/data.txt) # Pega o conteúravado no "data.txt" | |
# Backup | |
PGPASSWORD="x" pg_dump -h localhost -U postgres -F t database > /bkp/postgres/postgres-`hostname`-`date +%Y-%m-%d-`database-producao.tar | |
#RESTORE ON DEV DATABASE | |
PGPASSWORD="x" psql -U postgres -c "DROP DATABASE portal_dev;" | |
#PGPASSWORD="x" psql -U postgres -d database -f /bkp/postgres/postgres-`hostname`-`date +%Y-%m-%d-`database-producao.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment