Your IP is: 3.80.177.176

How to backup Postgres database on Alfresco under Linux

Setting up the Postgres database backup on Alfresco is a 3 step process. The steps to follow are:

  1. Create a Shell Script
  2. Create a Password File
  3. Setup Cronjob

1.Create a Shell Script

Before writing the script, you have to decide on the location of the script and the backup files

Once decides, we can then move to that script location and create our script file

 

Create a script dbbackup.sh by typing:

vi dbbackup.sh

Enter the following line in the dbbackup.sh file and save it

#! /bin/bash

/opt/alfresco40d/postgresql/bin/pg_dumpall -c -f /opt/BDRBackup/pg_dumpall.sql

Once saved, make the script executable by typing:

chmod x dbbackup.sh

 

2. Create a Password File

The password file is required to store the password of the postgres user

Go to the home directory of the user and create the file .pgpass by typing:

vi .pgpass

Enter the following line in the .pgpass file and save it

*:*:*:postgres:PASSWORD

Replace PASSWORD with the Postgres database user password

 

Once saved, change the permissions of the file. This will ensure that only the current user has permissions on the file

chmod 0600 .pgpass

 

3. Setup Cronjob

type the following to invoke the crontab for the user

crontab -e

enter the following line at the end to run the job every 5th minute

5  *  * * *   /opt/CustomCronJobs/dbbackup.sh

if you need further information on cronjobs, refer to https://ezref.info/How to set a Cron job in Linux.html

once saved, restart the cron daemon by typing

sudo service cron stop

sudo service cron start

Monitor the backup folder and check if the pg_dumpall.sql is created