Failures during backup
Anthirian opened this issue · comments
Describe the bug
I'm unable to back up the data using the CLI.
To Reproduce
Steps to reproduce the behavior:
- SSH into the server running Ghostwriter
- Change directory to the install folder
- Run
sudo ./ghostwriter-cli-linux backup
- Observe errors like below
Expected Behavior
A regular back up.
Screenshots
geert@ghostwriter:/opt/Ghostwriter$ sudo ./ghostwriter-cli-linux backup
[+] Checking the status of Docker and the Compose plugin...
[+] Backing up the PostgreSQL database for the production environment
[+] Running `docker` to back up the PostgreSQL database with production.yml...
Backing up the 'ghostwriter' database...
ERROR: Backing up as 'postgres' user is not supported. Assign 'POSTGRES_USER' env with another one and try again.
[-] Error from `docker`: exit status 1
2023/09/22 16:16:32 Error trying to back up the PostgreSQL database with production.yml: exit status 1
Server Specs:
-
OS: [e.g., Ubuntu]
$ cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.2 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.2 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy
-
Docker [e.g., output of
docker --version
anddocker-compose -v
]$ docker -v Docker version 24.0.5, build ced0996 $ docker compose version Docker Compose version v2.20.2
-
Ghostwriter [e.g., 2.2.3 or whatever is printed at the bottom of the left-hand sidebar]
$ sudo ./ghostwriter-cli-linux version Ghostwriter-CLI ( v0.2.16, 21 Sep 2023 )
Ghostwriter 4.0.0
Additional context
N/A
Hey @Anthirian,
The Postgres backup script Ghostwriter uses doesn't like that your user is the default postgres
account. It's a best practice to not use postgres
, but it can get in the way here. I've considered removing that check.
You can do that by editing this file and removing these lines: https://github.com/GhostManager/Ghostwriter/blob/master/compose/production/postgres/maintenance/backup#L23
You can also follow the steps outlined in this issue to change your user:
Thanks, I followed the suggestions and created the backup_user
and used the same password that Ghostwriter already set during install. Is there any reason not to do this by default during install?
You can change the user on install, but most people leave it at the default. That's fine, but then there is this conflict with the PostgreSQL maintenance scripts.
I can't find anything that states PostgreSQL backups and restores do not work with a user named postgres
. It's only in the community scripts. It looks like a safeguard against the postgres
user not working for backups on some *nix systems. It works without any issues in Ghostwriter's containers so I've removed the checks in the scripts for v4.0.1.