0

[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

  1. Set full permissions: sudo chmod -R 777 /opt/docker/my-docker-app/database/
  2. Used sudo for rclone sync operations
  3. Checked file ownership (all failed files owned by systemd-coredump)

Questions

  1. What's the proper way to handle file permissions during VPS migrations?
  2. Are there specific considerations for PostgreSQL db file permissions in Docker environments?
  3. Why I'm encounter this error?

Any help or guidance would be greatly appreciated!

1
  • How do you run your docker image? Rootless docker? What user is postgres configured to use? Commented Nov 3, 2024 at 12:08

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.