If you're using a PostgreSQL database and run this in Linux, it is possible to create automated back-ups. 

For this you can setup a "crontab" script which will run a bash shell. 


This will allow you to backup the data to your main server, to a cloud location or even to FTP. 

As the script must be customized per setup our support team needs to help you setting this up. The script will change depending the folder/location you will use. Below some examples and basic instructions. 


Step 1. Create a folder to where the backup will be saved. 

You can use a Folder Like Dropbox or a folder connected to your FTP. 


Step 2. Create a bash shell with the needed commands.

Open the terminal and give below commands: 


    a. sudo su

    b. cd Documents

    c. touch auto.sh 

    d. gedit auto.sh


Now a editor (gedit) will be opened in here you add below:

Important: The information in between the brackets ( "{" & "}" ) must be changed to your settings/values. 


#!/bin/bash

sudo su <<EOF


su - postgres

pg_dump -U postgres {database name} | gzip {folder location A}/{filename}.gz


rm {folder location B}/{filename}.gz 

mv {folder location A}/{filename}.gz


EOF



Explanation: 

{database name}

This will be the name of your Database, Like wipedrivedb


{filename}.gz

This will be the name of your backup file. 


{folder location A}

This will be the name of a folder to save the back up temporary. We advise this to be sure we have made a successful backup before we delete the previous one.  

This can be like /home/wd/Documents/Backup/temp/


{folder location B}

This will be the name of the final folder to save the back up.  

This can be like /home/wd/Documents/Backup/


Important: In /home/wd/Documents/  we show wd as computer name, this might be different for you. 


Save the file, and in the terminal you type below to make the file executable:

chmod +x auto.sh


Now the script is done and we can now make it launch via crontab, a task scheduler in Linux. 


In the terminal you type

crontab -e 

It will now ask to select an editor, use the suggested one. 


Scroll all the way down and add below text: 

0 10 * * * /home/wd/Documents/auto.sh 


Save the file: CTRL + O + ENTER  &  CTRL + X + ENTER


NOTES: 

/home/wd/Documents/ is the assuming folder, the wd part might be different for you. 


0 10 * * * means that every morning at 10 it will launch the file. You can change this to other times or only once a week. For this you need to change this string. Please refer to the source of crontab. 


Source: https://crontab.guru/ 


You're setup now. Please check after the time the first backup should be made if the script worked. 



If you need more information, please contact us via one of below options. 

 

          |   Email us    |   Submit a ticket   |   Give us a call   |

 

Our official support hours are 8:00 am to 16:30 pm, after those hours emailing us or submitting a ticket would be the best option.