To back up the postgresql database, you need to run the script SetPgCron
. The SetPgCron script enables or disables the cron job backupdb
. The cron backupdb
backs up the postgresql database located at /var/lib/pgsql/data
as a postgresql user and runs every day at 5 A.M. When you run the script, you can set the number of archives you want to retain and the path where you want to back up the database. No default path is assumed by the cron.
Important: The specified archive path must be a path on which the postgresql user has write permissions, otherwise the script fails with an error.
The files are backed up in the format db_dump_
<archiveno>.gz
, where <archiveno> is the nth archive in the list of archives created by the cron. On reaching the specified archive limit, the next backup overwrites the first archive.
The format of the script is as follows:
SetPgCron --enable -r
<no. of archive>-p
<backup path>
The following table explains the options.
Options |
Description |
---|---|
|
Indicates that the cron |
|
Indicates that the cron |
|
Indicates the number of archives that must be retained before the cron replaces the oldest archive with a new backup |
|
Indicates the complete path where you want to back up the database. No default path is assumed; if not specified, the script fails with an error. |
In the following example, the script enables the cron job to back up the postgresql database at /tmp
and retains 3 archives.
SetPgCron --enable -r3 -p/tmp/