Last active
July 10, 2020 12:27
-
-
Save fathonir/40d9f3bb0b52bede80ed1b877f6361da to your computer and use it in GitHub Desktop.
Backup Script PostgreSQL & MariaDB/MySQL
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
#!/usr/bin/bash #Centos | |
#!/bin/bash #Ubuntu | |
BACKUP_FILE=namadb_$(date +'%Y%m%d').sql | |
DB_USER=db_user | |
DB_NAME=db_name | |
SERVER_TARGET=login@ip:path | |
mysqldump -u $DB_USER $DB_NAME > $BACKUP_FILE && scp $BACKUP_FILE $SERVER_TARGET && rm -f $BACKUP_FILE |
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
#!/usr/bin/bash | |
# Harap memastikan ssh-nya sudah ssh-copy-id | |
BACKUP_FILE=namadb_$(date +'%Y%m%d').backup | |
DB_USER=db_user | |
DB_NAME=db_name | |
SERVER_TARGET=login@ip:path | |
pg_dump -U $DB_USER -F c -f $BACKUP_FILE $DB_NAME && scp $BACKUP_FILE $SERVER_TARGET && rm -f $BACKUP_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment