{"id":20263625,"url":"https://github.com/springerpe/cf-simple-backup","last_synced_at":"2025-09-08T18:34:20.325Z","repository":{"id":80987094,"uuid":"28135845","full_name":"SpringerPE/cf-simple-backup","owner":"SpringerPE","description":"Simple backup tool for CloudFoundry","archived":false,"fork":false,"pushed_at":"2015-10-12T14:07:16.000Z","size":234,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-03T19:59:36.103Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","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/SpringerPE.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}},"created_at":"2014-12-17T12:11:41.000Z","updated_at":"2015-08-05T21:32:11.000Z","dependencies_parsed_at":"2023-03-06T17:31:01.799Z","dependency_job_id":null,"html_url":"https://github.com/SpringerPE/cf-simple-backup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SpringerPE/cf-simple-backup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringerPE%2Fcf-simple-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringerPE%2Fcf-simple-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringerPE%2Fcf-simple-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringerPE%2Fcf-simple-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpringerPE","download_url":"https://codeload.github.com/SpringerPE/cf-simple-backup/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpringerPE%2Fcf-simple-backup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274229371,"owners_count":25245188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"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":"2024-11-14T11:35:45.056Z","updated_at":"2025-09-08T18:34:20.277Z","avatar_url":"https://github.com/SpringerPE.png","language":"Shell","readme":"cf-simple-backup\n================\n\nSimple backup script for a Cloud Foudry environment\n\nAbout cf-simple-backup\n=============================\n\nWarning! This information is about how to perform a manual recover \nof a Cloud Foundry environment.\n\nAssumptions:\n\n * stemcells are saved and up-to-date\n * manifest.yml is saved and up-to-date.\n\nAlso, the backup server has to be on the same network than the nfs blobstore, the\nreason is because it will mount the blobstore on the NFS server in RO mode, and\ncopy the files using `rsync`.\n\n\nSetup\n=====\n\nThe script works by reading a configuration file with some variables. You can pass\nthe configuration file as an argument (`-c`), but the script is able to read\nit automatically if one exists with the same name as the program (except the suffix).\n\nSo, by creating a links to the script and multiple configuration files with\nthe same name (only changing the sufix `.sh` into `.conf`) and using different \nvariables, is possible to backup different CF environments.\n\nRun the backup\n==============\n\n```\n# ./cf-simple-backup-test.sh backup\n--cf-simple-backup-test.sh 2014-12-21 17:16:03: Targeting and login microbosh 10.10.10.10 ... done!\n--cf-simple-backup-test.sh 2014-12-21 17:16:06: Getting bosh status ... ok\n--cf-simple-backup-test.sh 2014-12-21 17:16:16: Getting bosh manifest for dev ... cf_manifest_20141221171603.yml\n--cf-simple-backup-test.sh 2014-12-21 17:16:19: Locating db and nfs hosts ... done!\n--cf-simple-backup-test.sh 2014-12-21 17:16:19: Pinging 10.10.10.11 and 10.10.10.12 ... ok\n--cf-simple-backup-test.sh 2014-12-21 17:16:23: Checking if 10.10.10.12:/var/vcap/store is mounted ... ok, not mounted\n--cf-simple-backup-test.sh 2014-12-21 17:16:23: Starting DB backup.\n--cf-simple-backup-test.sh 2014-12-21 17:16:23: Dumping database ccdb ... done!\n--cf-simple-backup-test.sh 2014-12-21 17:16:24: Dumping database uaadb ... done!\n--cf-simple-backup-test.sh 2014-12-21 17:16:24: Mounting blobstore 10.10.10.12:/var/vcap/store on /tmp/cf-simple-backup-test.sh_20981 ... done!\n--cf-simple-backup-test.sh 2014-12-21 17:16:24: Copying files with rsync ... done!\n--cf-simple-backup-test.sh 2014-12-21 17:17:02: Umounting remote blobstore: sudo umount -f /tmp/cf-simple-backup-test.sh_20981 ... done\n--cf-simple-backup-test.sh 2014-12-21 17:17:02: Adding extra files: /backups/bin/cf-recovering.txt \n--cf-simple-backup-test.sh 2014-12-21 17:17:02: Creating /backups/dev/cf/cf_test_20141221171603.tgz ... done\n```\n\nIf something went wrong it will finish with an error (return code not 0) and\nit will show the error log. Moreover, the program only performs the backup if \nthe CF nfsserver is not mounted on the server.\n\nThe script logs almost everything on _/var/log/scripts_ and also includes\na copy of this logfile within the output tar file.\n\n\nRecovery\n========\n\nNotes:\n* BOSH_WORKSPACE is a place where you can run the bosh client `bosh` and you have your manifests around.\n\n```\n# Gather the IPs of the VMs running postgres and nfs\n$ cd BOSH_WORKSPACE\n$ bosh vms | awk '/ postgres_| nfs_/{ print $2\" --\u003e \"$8 }'\nnfs_z1/0 --\u003e n.n.n.n\npostgres_z1/0 --\u003e n.n.n.n\n\n# Stop all api_worker, api, nfs and uaa services. Note that depending on your installation there could be more (or less) services than listed below.\n# (order might be important)\n$ bosh deployment ENV/manifests/RELASE_VERSION.yml\n$ bosh stop api_z1 --soft\n$ bosh stop api_z2 --soft\n$ bosh stop api_worker_z1 --soft\n$ bosh stop api_worker_z2 --soft\n$ bosh stop nfs_z1 --soft\n$ bosh stop uaa_z1 --soft\n$ bosh stop uaa_z2 --soft\n\n# Log in to nfs server and prepare for restoring the data\n$ ssh -l vcap NFS_IP\n$ sudo rm -rf /var/vcap/store/*\n$ sudo mkdir /var/vcap/store/tmp\n$ sudo chown vcap.vcap /var/vcap/store/tmp\n\n# Log in to the backup server and copy the nfs data\n$ ssh BACKUP_SERVER\n$ rsync -arzhv /backups/ENV/cf/cache/store/ vcap@NFS_IP:/var/vcap/store/tmp\n\n# Log in to the nfs server and copy the data into the correct folder\n$ ssh -l vcap NFS_IP\n$ sudo mv /var/vcap/store/tmp/* /var/vcap/store/\n$ sudo rmdir /var/vcap/store/tmp/\n\n# Log in to the backup server and copy the postgres dumps to the VM running postgres\n$ ssh BACKUP_SERVER\n$ scp /backups/ENV/cf/cache/dbs/* vcap@POSTGRES_IP:/var/vcap/store/postgres\n\n# Log in to the postgres VM and restore the dumps\n$ ssh -l vcap POSTGRES_IP\n$ cd /var/vcap/store/postgres\n$ sudo /var/vcap/bosh/bin/monit restart postgres  # terminates possible remaining open sessions\n$ /var/vcap/packages/postgres/bin/psql -h 127.0.0.1 -p 5524 -U vcap postgres \u003c $POSTGRES_UAADB  # File e.g. 'postgres_20150210110858.dump.uaadb'\n$ /var/vcap/packages/postgres/bin/psql -h 127.0.0.1 -p 5524 -U vcap postgres \u003c $POSTGRES_CCDB  # File e.g. 'postgres_20150210110858.dump.ccdb'\n$ rm $POSTGRES_UAAB\n$ rm $POSTGRES_CCDB\n\n# Start the services again (order might be important)\n$ cd BOSH_WORKSPACE\n$ bosh start nfs_z1\n$ bosh start uaa_z1\n$ bosh start uaa_z2\n$ bosh start api_z1\n$ bosh start api_z2\n$ bosh start api_worker_z1\n$ bosh start api_worker_z2\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspringerpe%2Fcf-simple-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspringerpe%2Fcf-simple-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspringerpe%2Fcf-simple-backup/lists"}