This project solves the Backup restore challenge from hackattic.com.
- Python 3.x
- Docker and Docker Compose
- PostgreSQL client tools (psql) - usually included with PostgreSQL installation
- API token from
https://hackattic.com/challenges/backup_restore
Start the PostgreSQL database container:
docker-compose up -dThis will:
- Start a PostgreSQL 10 container
- Create a database named
hackattic - Expose PostgreSQL on port
5432 - Use credentials:
postgres/postgres
Wait for the database to be ready (the healthcheck will ensure it's up).
Create a virtual environment to isolate project dependencies:
python3 -m venv .venvOn macOS/Linux:
source .venv/bin/activateOn Windows:
venv\Scripts\activateInstall the required Python packages:
pip install -r requirements.txtThis will install:
psycopg2==2.9.11(PostgreSQL adapter for Python)
Run the solve script with your Hackattic access token:
python solve.py <your_access_token>The script will:
- Fetch the database dump from Hackattic
- Decode and decompress the dump
- Load it into the PostgreSQL database
- Query for SSNs with status 'alive'
- Submit the solution to Hackattic
When you're done, you can stop the database container:
docker-compose downTo also remove the volume (and all data):
docker-compose down -v- Database connection errors: Make sure Docker Compose is running and the database is healthy
- psql not found: Install PostgreSQL client tools or use Docker to run psql commands
- Permission errors: Ensure Docker has proper permissions to run containers