A simple library to make auto backups of PostgreSQL database instances.
There are two ways to install this library:
- Docker
- Directly from sources
-
Clone this repository using
git clone https://github.com/varijkapil13/auto-backup.git -
Add your database configuration to
server.inifile.[localhost] url = localhost port = 5432 username = postgres password = password database = testdbUsing this configuration the script will create a folder named
localhost(taken from the block[localhost]) and save the backups in that directory with time stampsMore than one database servers can be added to the file. Below is an example configuration for such a setting:
[localhost] url = localhost port = 5432 username = postgres password = password database = testdb [My other server] url = otherserver.com port = 5432 username = postgres password = password database = testdbUsing this configuration the script will create two folders named
localhostandMy other serverand save the backups in these directories with time stamps. -
Create docker container using
docker build -t vk-auto-backup:latest . && docker run -v /Users/varijkapil13/backups:/app/Backups/ --name vk-auto-backup vk-auto-backup:latestReplace
/Users/varijkapil13/backupswith path to the folder where you want to store your backups. -
The application is now in a docker container and will automatically backup your databases everyday at 00:00 Hours.
-
Clone this repository using
git clone https://github.com/varijkapil13/auto-backup.git -
Install virtualenv.
pip install virtualenv -
Create a virtual environment and activate it.
virtualenv venvsource venv/bin/activate -
Add your database configuration to
server.inifile.[localhost] url = localhost port = 5432 username = postgres password = password database = testdbUsing this configuration the script will create a folder named
localhost(taken from the block[localhost]) and save the backups in that directory with time stampsMore than one database servers can be added to the file. Below is an example configuration for such a setting:
[localhost] url = localhost port = 5432 username = postgres password = password database = testdb [My other server] url = otherserver.com port = 5432 username = postgres password = password database = testdbUsing this configuration the script will create two folders named
localhostandMy other serverand save the backups in these directories with time stamps. -
Run the script using:
python3 backup.pyThe script will backup your database at 00:00 Hours to folder
.../path/to/app/auto-backup/Backups/. It will only create the backup once. To make it run automoatically you will have to link the script with some external service linksupervisor.dor ininit.din Ubuntu