CLI for backing up remote PostgreSQL databases locally or to AWS S3
$ pip3 install --user pipenv
$ pipenv --python $(which python3)
git clone https://github.com:example/pgbackup
cd pgbackup && make install
pipenv shell
Pass in a full database URL, the storage driver, and destination.
$ pip install -e .
$ pip uninstall pgbackup
$ pgbackup postgres://[email protected]:5432/db_one --driver s3 backups
$ pgbackup postgres://[email protected]:5432/db_one --driver local /var/local/db_one/backups
$ make
$ pipenv run make
(pgbackup) ➜ pgbackup git:(main) ✗ PYTHONPATH=./src python3
>>> from pgbackup import pgdump
>>> proc = pgdump.dump('postgres://user:password@localhost:5432/sample')
>>> f = open('./db/dump.sql', 'wb')
>>> f.write(proc.stdout.read())
>>> f.close()
Edit or Create this file
setup.cfg
Build the wheel
python setup.py bdist_wheel
Install package with wheel package
pip install dist/package_name.whl
Upload package on S3 `` >>> import boto3 >>> client = boto3.client('s3') >>> f = open('dist/pgbackup-0.1.0-py37-none-any.whl', 'rb') >>> client.upload_fileobj(f, 'your-bucket-name', 'pgbackup-0.1.0-py37-none-any.whl') >>> exit() ``
This document is based on reStructuredText tool.