Simple Database Backup

Recently I was needed to make daily backup of database. This is always a good idea to have most reacent backup of data or source codes. But daily backups… Sound like a perfect task for automation! Most of a time I’m working with PostgreSQL database. And example implemets backups for same db. The bash script: #!/bin/bash date=$(date '+%Y-%m-%d') PGPASSWORD="database_password" \ pg_dump \ --host 127.0.0.1 \ --port 5432 \ -U database_user \ --verbose \ --file "backups/DB_backup_$date....

August 15, 2023

Alembic - Basic Usage

This is not tutorial - it’s my understanding! If I’m worng - let me know. Before dive into the tutorial - first read Alembic getting started manual. Setup After you setup your working enviroment ( env, pip, sqlalchemy etc. ) run: $ alembic init alembic This command will add alembic folder ( with banch of folder and files in it ) and alembic.ini file. In alembic.ini change sqlalchemy.url variable in [alembic] section to your database connection string....

August 12, 2023