{"id":16367673,"url":"https://github.com/torstein-eide/pg_backup","last_synced_at":"2026-03-08T10:39:55.541Z","repository":{"id":247907620,"uuid":"183823447","full_name":"Torstein-Eide/PG_backup","owner":"Torstein-Eide","description":"Update script for postgreSQL server on linux, hourly and daily ","archived":false,"fork":false,"pushed_at":"2024-07-11T07:33:21.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-02T20:46:20.455Z","etag":null,"topics":["backup","pgsql","postgresql"],"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/Torstein-Eide.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-27T21:31:27.000Z","updated_at":"2024-07-11T06:55:50.000Z","dependencies_parsed_at":"2024-07-11T09:13:32.099Z","dependency_job_id":null,"html_url":"https://github.com/Torstein-Eide/PG_backup","commit_stats":null,"previous_names":["torstein-eide/pg_backup"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Torstein-Eide/PG_backup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torstein-Eide%2FPG_backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torstein-Eide%2FPG_backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torstein-Eide%2FPG_backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torstein-Eide%2FPG_backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Torstein-Eide","download_url":"https://codeload.github.com/Torstein-Eide/PG_backup/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torstein-Eide%2FPG_backup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30253837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T08:59:44.879Z","status":"ssl_error","status_checked_at":"2026-03-08T08:58:02.867Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["backup","pgsql","postgresql"],"created_at":"2024-10-11T02:50:34.271Z","updated_at":"2026-03-08T10:39:55.524Z","avatar_url":"https://github.com/Torstein-Eide.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# backup of PostgreSQL database\nnote: this script runs unsecured connection, so don't use it over the internet.\n\n## get the scripts:\n```\ninstall -d /etc/scripts\n\ncd /etc/scripts\n```\n\n```\nwget https://raw.githubusercontent.com/Eideen/backupMysql/master/pgsql_backup_daily.sh\nwget https://raw.githubusercontent.com/Eideen/backupMysql/master/pgsql_backup_common.sh\nwget https://raw.githubusercontent.com/Eideen/backupMysql/master/pgsql_backup_horly.sh\nchmod +x ./pgsql_backup*.sh\nchmod 700 ./pgsql_backup_common.sh\n```\n## make a backup user:\n* HOSTNAME\nServer that the script is running on.\n* DB_USERNAME\ndatabase backup username\n* DB_PASSWORD\ndatabase backup user passowrd, make a random password.\n\n### A way to make a password:\n```\ndate +%s | sha256sum | base64 | head -c 32 ; echo\n```\n## On the mysql server:\n```bash\n#### fix me\nsudo -u postgres psql\nCREATE ROLE readaccess;\nCREATE USER backupuser WITH PASSWORD '123';\nGRANT CONNECT ON DATABASE postgres  TO readaccess;\nGRANT USAGE ON SCHEMA public TO readaccess;\nGRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;\nGRANT readaccess TO backupuser;\n\\q\n## old\n\nGRANT CONNECT ON DATABASE mydb TO backupuser;\nGRANT SELECT ON ALL TABLES IN SCHEMA mySchema TO backupuser;\nALTER DEFAULT PRIVILEGES IN SCHEMA mySchema\nGRANT SELECT ON TABLES TO backupuser;\n\n```\n## edit the scripts to fit your setup:\n* DB_USERNAME\ndatabase backup username, it is recommend to use a dedicated backup user.\n* DB_PASSWORD\ndatabase backup user passowrd\n* DB_HOSTNAME\ndatabase backup hostname\n* DEST\npath you wanted to save the backup\n* TEMPdir\npath to temporary store datebase files before\n* EMAIL\nyour mail, if you wanted to send mail to you. you also need to make sure you have setup `ssmtp`.\n* DAYS\nNumber of days to save.\n* SKIP\nDatabases to skip.\ndefault is `information_schema` and `performance_schema`. One line per datebase.\n```\nNano pgsql_backup_horly.sh pgsql_backup_daily.sh\n```\n\n## Now test your script:\n```\n/etc/scripts/pgsql_backup_horly.sh\n/etc/scripts/pgsql_backup_daily.sh\n```\noutput example:\n\u003e```\n\u003elist of databases:\n\u003e* information_schema\n\u003e* pgsql\n\u003e* performance_schema\n\u003efolder /volum/@backup/mysql/daglig exist\n\u003eskiping   information_schema\n\u003eskiping   performance_schema\n\u003eextracted mysql in 0 cpu seconds\n\u003email not setup\n\u003eMySQL backup is completed without export fail\n\n## you can control the content of the backup with the following commands:\n ```\n tar -tvf $DEST/$NOW.tar.gz\n ```\nexample:\n\u003e```\n\u003e # tar -tvf /volum/@backup/mysql/daglig/[backupfile].tar.gz\n\u003edrwxr-xr-x root/root         0 2018-11-11 11:32 2018-11-11_1132/\n\u003edrwx------ root/root         0 2018-11-11 11:32 2018-11-11_1132/mysql/\n\u003e-rw-r--r-- root/root       831 2018-11-11 11:32 2018-11-11_1132/mysql/mysql.sql\n\u003e ```\n## restore database:\n ```\ntar -xf [backupfile].tar.gz\ncd .[backupfile]/mysql/\nmysqladmin -u root -p[root_password] create[database_name]\nmysql -u root -p[root_password] [database_name] \u003c dumpfilename.sql\n ```\n## Setup crontab:\n```\necho \"#mysql database backup\n32 1 * * * root /etc/scripts/db_backup_daglig.sh \u003e /dev/null 2\u0026\u003e1\n44 * * * * root /etc/scripts/db_backup_horly.sh  \u003e /dev/null 2\u0026\u003e1\" | tee /etc/cron.d/backup_MYsql\n```\n### Verfie that cron is working\n```\ngrep \"/etc/tilpasset/db_backup_horly.sh\" /var/log/syslog\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorstein-eide%2Fpg_backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftorstein-eide%2Fpg_backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorstein-eide%2Fpg_backup/lists"}