Backup failure when temp backup file is moved to backups/default directory

AI-generated summary

ckshen faced issues while moving a temporary backup file to the /var/www/discourse/public/backups/default/ directory, resulting in a permission denied error. The issue was likely caused by a difference in permissions between the temporary and public backup directories. Ed_S analyzed the ownership and protection details of the directories and suggested that the manual creation of a directory might have caused the problem. Jagster raised the question of whether the app inside the Docker container could access the system outside the container. pfaffman suggested deleting the manually created directory /var/discourse/shared/standalone/backups/default/ as a potential solution. Surprisingly, the backup process started working successfully without any changes made to the system.

The creation of the temporary backup file went smoothly. Its when the file is moved from /var/www/discourse/tmp/backups/default/ to /var/www/discourse/public/backups/default/
that issues surface.

[2024-01-28 05:47:54] EXCEPTION: /var/www/discourse/lib/discourse.rb:137:in `exec': Failed to move database dump file.
mv: cannot move '/var/www/discourse/tmp/backups/default/2024-01-28-054559/dump.sql.gz' to '/var/www/discourse/public/backups/default/hungry-onion-2024-01-28-054559-v20230728055813.sql.gz': Permission denied

How do I address this issue?

Separately, does this issue have anything to do with the fact that I previously created the /var/discourse/shared/standalone/backups/default/ folder (outside the container) myself when I used command line to restore a backup on a new instance?

The permission right now is drwxrwxr-x 2 1000 www-data 4096 Jan 27 17:35 default

Those two locations are (normally) on the same disk, so it can’t be disk space trouble, so indeed I think it must be permission trouble. Of course backups will normally work - assuming you did a standard install - and so it seems likely that your manual creation of a directory has something to do with the trouble.

But. I checked on my machine, and the ownership and protection is like this, inside the container:

root@ubuntu-2gb-nbg1-1-app:/var/www/discourse# ls -ltrd /var/www/discourse/tmp/backups/default /var/www/discourse/public/backups/default
drwxr-xr-x 2 discourse www-data 4096 Jan 24 03:36 /var/www/discourse/tmp/backups/default
drwxr-xr-x 2 discourse www-data 4096 Jan 24 03:36 /var/www/discourse/public/backups/default
root@ubuntu-2gb-nbg1-1-app:/var/www/discourse# ls -nltrd /var/www/discourse/tmp/backups/default /var/www/discourse/public/backups/default
drwxr-xr-x 2 1000 33 4096 Jan 24 03:36 /var/www/discourse/tmp/backups/default
drwxr-xr-x 2 1000 33 4096 Jan 24 03:36 /var/www/discourse/public/backups/default
root@ubuntu-2gb-nbg1-1-app:/var/www/discourse# ls -nltrd /var/www/discourse/tmp/backups /var/www/discourse/public/backups
lrwxrwxrwx 1 0 0 19 Jan 10 15:26 /var/www/discourse/tmp/backups -> /shared/tmp/backups
lrwxrwxrwx 1 0 0 15 Jan 10 15:26 /var/www/discourse/public/backups -> /shared/backups
root@ubuntu-2gb-nbg1-1-app:/var/www/discourse# ls -nltrd /var/www/discourse/tmp /var/www/discourse/public
drwxr-xr-x 1 1000 1000 12288 Jan 10 15:31 /var/www/discourse/public
drwxr-xr-x 1 1000   33  4096 Jan 10 15:36 /var/www/discourse/tmp
root@ubuntu-2gb-nbg1-1-app:/var/www/discourse# ls -nltrd /var/www/discourse
drwxr-xr-x 1 1000 1000 4096 Jan 10 15:26 /var/www/discourse
root@ubuntu-2gb-nbg1-1-app:/var/www/discourse# ls -nltrd /shared/backups /shared/tmp/backups
drwxr-xr-x 3 1000 33 4096 Aug 15  2019 /shared/backups
drwxr-xr-x 3 1000 33 4096 Jan 10 15:36 /shared/tmp/backups
root@ubuntu-2gb-nbg1-1-app:/var/www/discourse# ls -nltrd /shared /shared/tmp
drwxr-xr-x 13    0  0 4096 Jan 27  2021 /shared
drwxr-xr-x  4 1000 33 4096 Jan 10 15:35 /shared/tmp

The 1000 user is “discourse” and the 33 group is “www-data” and all of this doesn’t give me a clue as to what your problem is. Sorry.

Can app inside docker see the system outside docker? I’m living in the believe it can’t be done that way.

Probably. Try deleting it.

I am not really sure what happened. But yesterday night the system backed up successfully. Today I manually backed up also successfully. I made no change to the system between now and then.

Oh well.