File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ #
3
+ # Author: Outhan Chazima
4
+ # Date : 26-May-2022
5
+ # Description : The backup script will complete the backup and send the backup to a remote server.-
6
+ #
7
+
8
+ # # In below given variables - require information to be feed by system admin##.
9
+
10
+ _BACKUP_DIR=/home/DBbackup/postgres
11
+ _DATABASE_NAME=postgres
12
+
13
+ # This requires you to have configyres the remote server ssh keys to be able to connect to remote server
14
+ _REMOTE_BACKUP_SERVER_ADDRESS=user@remote_server_ip
15
+
16
+
17
+ # # Do not edit below given variable ##
18
+
19
+ _DATE_SCHEMA=$( date +%F-%H%M-%S)
20
+ _BACKUP_FILE=postgres-backup-$_DATE_SCHEMA .tar.gz
21
+ _BACKUP_PATH=$_BACKUP_DIR
22
+
23
+ # ##### Create / check backup Directory ####
24
+
25
+ if [ -d " $_BACKUP_PATH " ]
26
+ then
27
+ echo " $_BACKUP_PATH already exist"
28
+ else
29
+ mkdir -p " $_BACKUP_PATH "
30
+ fi
31
+
32
+
33
+ # #################### SECTION 1 : SCHEMA BACKUP ############################################
34
+ pg_dump $_DATABASE_NAME | gzip > $_BACKUP_PATH /$_BACKUP_FILE
35
+
36
+ # #################### END OF LINE ---- SECTION 1 : SCHEMA BACKUP #####################
37
+
38
+ scp $_BACKUP_PATH /$_BACKUP_FILE $_REMOTE_BACKUP_SERVER_ADDRESS :$_BACKUP_DIR ;
39
+
40
+ done%
You can’t perform that action at this time.
0 commit comments