[Help] PostgreSQL Permission Denied After Docker Migration Between VPS Using rclone
Problem
I'm getting permission denied errors while trying to set modification times on PostgreSQL files after migrating a Docker setup between VPS instances. Even with full permissions (777) and sudo, the errors persist.
Current Approach
- Trying to migrate the entire Docker directory structure (not using pg_dump)
- Stopped PostgreSQL containers on both VPS 1 and VPS 2 before migration
- Note: I'm aware pg_dump works fine, but specifically need to migrate the entire folder structure
Environment
- Docker container app running PostgreSQL
- Migration from VPS 1 to VPS 2
- Path:
/opt/docker/my-docker-app/database/
Rclone Commands
- My function:
sync_operation() { local source="$1" local destination="$2" sudo rclone sync "$source" "$destination" \ --sftp-host "$SSH_HOST" \ --sftp-port "$SSH_PORT" \ --sftp-user "$SSH_USER" \ # not root --sftp-key-file "$SSH_KEY" \ --create-empty-src-dirs \ --progress } - Example of usage:
SOURCE_DIR="/opt/docker/my-docker-app/database" # in VPS 1 DEST_DIR="/opt/docker/my-docker-app/database" # in VPS 2 sync_operation "$SOURCE_DIR" ":sftp:$DEST_DIR" Error Messages
ERROR : /my-docker-app/database/data/base/16384/13404: Failed to set modification time: SetModTime failed: permission denied ERROR : /my-docker-app/database/data/base/16384/13406: Failed to set modification time: SetModTime failed: permission denied ERROR : /my-docker-app/database/data/PG_VERSION: Failed to set modification time: SetModTime failed: permission denied What I've Tried
- Set full permissions:
sudo chmod -R 777 /opt/docker/my-docker-app/database/ - Used sudo for rclone sync operations
- Checked file ownership (all failed files owned by systemd-coredump)
Questions
- What's the proper way to handle file permissions during VPS migrations?
- Are there specific considerations for PostgreSQL db file permissions in Docker environments?
- Why I'm encounter this error?
Any help or guidance would be greatly appreciated!