{"id":30852509,"url":"https://github.com/chfern/bucardo-sandbox","last_synced_at":"2026-02-12T07:03:22.867Z","repository":{"id":106048403,"uuid":"332492012","full_name":"chfern/bucardo-sandbox","owner":"chfern","description":"Bucardo sandbox to sync 2 DBs","archived":false,"fork":false,"pushed_at":"2021-01-24T16:14:26.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-07T08:21:05.060Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chfern.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-01-24T16:03:32.000Z","updated_at":"2021-01-24T16:14:28.000Z","dependencies_parsed_at":"2023-11-07T00:47:11.336Z","dependency_job_id":"2f292dc1-3e6b-442d-ba59-2f936bbe03d1","html_url":"https://github.com/chfern/bucardo-sandbox","commit_stats":null,"previous_names":["chfern/bucardo-sandbox"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chfern/bucardo-sandbox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chfern%2Fbucardo-sandbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chfern%2Fbucardo-sandbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chfern%2Fbucardo-sandbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chfern%2Fbucardo-sandbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chfern","download_url":"https://codeload.github.com/chfern/bucardo-sandbox/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chfern%2Fbucardo-sandbox/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29360729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T01:03:07.613Z","status":"online","status_checked_at":"2026-02-12T02:00:06.911Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-07T08:05:37.963Z","updated_at":"2026-02-12T07:03:22.851Z","avatar_url":"https://github.com/chfern.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bucardo Sandbox\n\nA sandbox about replicating data from 1 postgres DB to another using [bucardo](https://bucardo.org/).  \nThis sandbox uses docker-compose for linux package installation and database creation only (this is intentional).\n\nVersions used:  \n- PostgreSQL - 11.9\n- Bucardo - 5.6.0\n\n## Scenario\n\nWe would have 2 databases (source database and destination database). Data in some tables would then be synced from src to dest DB.\n\nSource host: 192.168.99.3  \nSource database: booking-db  \nSource port: 5432  \nSource username: postgres  \nSource password: AAAaaa123!@#\n\nDestination host: 192.168.99.3  \nDestination database: booking-db  \nDestination port: 6432  \nDestination username: postgres  \nDestination password: AAAaaa123!@#\n\nTables to-sync from source database:  \n- `schema_to_migrate.bookings`\n- `schema_to_migrate.booking_histories`\n\n# Running the Sandbox\n\n## Pre-requisites\n\nYou need to have these installed in your system beforehand:  \n- Docker\n- Docker Compose\n- Any DB GUI or psql to inspect the database later on\n\n## Sandbox Setup\n\nSetup static IP on host  \n`sudo ifconfig lo0 alias 192.168.99.3`\n\nIn the root project directory, run `docker-compose up`. This spawns the 2 database containers with required linux packages and postgres plugin.\n\nExecute bash using root user in source postgres container by running `docker exec -u root -it $(docker ps -aqf \"name=postgres-11-src$\") /bin/bash`\n\n### Environment Variables Setup\n\nFor convenience purpose, set the informations to env variables\n```\nexport SOURCE_HOST=192.168.99.3\nexport SOURCE_PORT=5432\nexport SOURCE_DATABASE=booking-db\nexport SOURCE_USERNAME=postgres\nexport SOURCE_PASSWORD='AAAaaa123!@#'\n\nexport DEST_HOST=192.168.99.3\nexport DEST_PORT=6432  \nexport DEST_DATABASE=booking-db  \nexport DEST_USERNAME=postgres\nexport DEST_PASSWORD='AAAaaa123!@#'\n\nexport TABLES=\"schema_to_migrate.bookings schema_to_migrate.booking_histories\"\n```\n\n### Source Database \u0026 Destination Database Setup\n\nConnect to the src database using psql to create tables and optionally seed dummy data.  \n```\npsql -U $SOURCE_USERNAME -h $SOURCE_HOST $SOURCE_DATABASE\n\nCREATE SCHEMA schema_to_migrate;\nCREATE TABLE schema_to_migrate.bookings(booking_id int primary key);\nCREATE TABLE schema_to_migrate.booking_histories(booking_history_id int primary key);\n\nINSERT INTO schema_to_migrate.bookings(booking_id) values (1);\n\n\\q\n```\n\nBecause destination database is freshly deployed, dump schema info from source database and update destination database with the schema information\n```\ncd /tmp \u0026\u0026 \\\npg_dump -U $SOURCE_USERNAME -d $SOURCE_DATABASE --schema-only --no-privileges --no-owner --no-security-labels --no-synchronized-snapshots --no-tablespaces \u003e schema.sql \u0026\u0026 \\\npsql -h $DEST_HOST -p $DEST_PORT -d $DEST_DATABASE -U $DEST_USERNAME -f schema.sql\n```\n\n### Bucardo Setup\n\nCreate a new linux user for bucardo\n```\nexport BUCARDO_USER=bucardo\n\nsudo useradd $BUCARDO_USER -m \u0026\u0026 \\\nsudo passwd $BUCARDO_USER\n```\n\nDownload bucardo distribution in well-known `src` folder\n```\ncd /usr/local/src \u0026\u0026 \\\nwget https://github.com/bucardo/bucardo/archive/5.6.0.tar.gz \u0026\u0026 \\\ntar zxvf 5.6.0.tar.gz \u0026\u0026 \\\nrm 5.6.0.tar.gz \u0026\u0026 \\\ncd bucardo-5.6.0 \u0026\u0026 \\\nperl Makefile.PL \u0026\u0026 \\\nmake \u0026\u0026 \\\nmake install \u0026\u0026 \\\nsudo chown -R $BUCARDO_USER:$BUCARDO_USER /usr/local/src/bucardo-5.6.0\n```\n\nCreate other folders required by bucardo  \n```\nsudo mkdir -p /var/log/bucardo /var/run/bucardo \u0026\u0026 \\\nsudo chown $BUCARDO_USER:$BUCARDO_USER /var/log/bucardo /var/run/bucardo\n```\n\nSwitch to `bucardo` user then [re-apply the env variables](#environment-variables-setup)\n```\nsu -l bucardo\n```\n\n### Configuring Bucardo's PostgreSQL\n\nCreate .pgpass file to connect to local and destination DB, then secure it due to it containing credential information\n```\ncat \u003e $HOME/.pgpass \u003c\u003cEOL  \n$DEST_HOST:$DEST_PORT:$DEST_DATABASE:$DEST_USERNAME:$DEST_PASSWORD\n$SOURCE_HOST:$SOURCE_PORT:$SOURCE_DATABASE:$SOURCE_USERNAME:$SOURCE_PASSWORD\nEOL\n\nchmod 0600 $HOME/.pgpass\n```\n\nIn the bucardo directory, trigger bucardo installation. Change the config such that it match the configuration below then proceed with the installation\n```\ncd /usr/local/src/bucardo-5.6.0 \u0026\u0026 \\\n./bucardo install --quiet\n```\n\n```\n1. Host:           192.168.99.3 \n2. Port:           5432  \n3. User:           postgres  \n4. Database:       booking-db  \n5. PID directory:  /var/run/bucardo \n```\n\n### Configuring Bucardo Sync\n\nAdd source database\n```\n./bucardo add db source_db dbhost=$SOURCE_HOST dbport=$SOURCE_PORT dbname=$SOURCE_DATABASE dbuser=$SOURCE_USERNAME dbpass=$SOURCE_PASSWORD\n```\n\nAdd destination database\n```\n./bucardo add db dest_db dbhost=$DEST_HOST dbport=$DEST_PORT dbname=$DEST_DATABASE dbuser=$DEST_USERNAME dbpass=$DEST_PASSWORD\n```\n\nAdd tables to migrate\n```\n./bucardo add tables $TABLES db=source_db\n./bucardo add herd copying_herd $TABLES\n```\n\nAnd build a sync based on the \"copying herd\"\n```\n./bucardo add sync booking_sync relgroup=copying_herd dbs=source_db:source,dest_db:target onetimecopy=2\n```\n\nSet bucardo's database credential info bucardo's config file\n```\ncat \u003e $HOME/.bucardorc \u003c\u003cEOL\ndbhost=$SOURCE_HOST \ndbname=bucardo\ndbport=$SOURCE_PORT\ndbuser=bucardo  \nEOL\n```\n\nRun bucardo to start sync process\n```\n./bucardo start\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchfern%2Fbucardo-sandbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchfern%2Fbucardo-sandbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchfern%2Fbucardo-sandbox/lists"}