Backup Failed Due to Permissions?

I’m getting a backup error with

[2020-10-17 23:40:29] EXCEPTION: lib/discourse.rb:92:in `exec': tar: /var/www/discourse/public/backups/default/bringing-data-to-life-2020-10-17-234010-v20200916085541.tar: Cannot open: Permission denied
tar: Error is not recoverable: exiting now

I’ve logged into the container, went to the directory and confirmed the root user can create files.

I changed the permissions to 777 and the backup worked. Even though this is private site I’m not keen on leaving 777 permissions on a possibly public link.

Does the backup process run with a different user from root?

Hopefully, yes. Try chowning it to discourse.

1 Like

I just tested it in a Docker container and everything seems to be fine:

root@gerhard-test-app:/shared/backups/default# ls -la
total 29068
drwxr-xr-x 2 discourse www-data     4096 Oct 18 09:51 .
drwxr-xr-x 3 discourse www-data     4096 Sep 18 15:31 ..
-rw-r--r-- 1 discourse www-data  7606150 Oct 18 09:48 discourse-test-site-2020-10-18-094806-v20201009190955.tar.gz
-rw-r--r-- 1 discourse discourse 7627995 Oct 18 09:51 discourse-test-site-2020-10-18-095138-v20201009190955.tar.gz

The first backup was created in the web interface. The second one was created with discourse backup command.

/var/www/discourse/public/backups is a symlink:

root@gerhard-test-app:/var/www/discourse/public# ls -la backups
lrwxrwxrwx 1 root root 15 Oct 18 09:42 backups -> /shared/backups