# Database Management

# Migrating an existing database (Linux)

  1. To Take a database dump of your existing database run the following command on the original VM.
sudo su postgres -c "pg_dump filemage --format=custom --file=/tmp/filemage_db.backup"
  1. Copy the backup file to the target VM.

  2. Run the following commands on the target VM.

sudo systemctl stop filemage
sudo su postgres -c "pg_restore /tmp/filemage_db.backup --clean --create --dbname postgres"
sudo systemctl start filemage

Note

This command will drop the existing filemage database on the target VM. If no filemage database exists on the target instance you will see a warning about DROP DATABASE failing but the operation will succeed.

# Migrating an existing database (Windows)

  1. To take a database dump of your existing database run the following command in the command prompt on the original VM. When prompted for a password enter postgres.
"C:\Program Files\PostgreSQL\12\bin\pg_dump" -F custom -f filemage_db.backup -d filemage -U postgres
  1. Copy the backup file to the target VM.

  2. Stop the FileMage Gateway service in the Windows service manager on the target VM.

  3. Run the following command on the target VM.

"C:\Program Files\PostgreSQL\12\bin\pg_restore" -d filemage -U postgres --clean filemage_db.backup
  1. Start the FileMage Gateway service in the Windows service manager on the target VM.

Note

This command will drop the existing filemage database on the target VM. If no filemage database exists on the target instance you will see a warning about DROP DATABASE failing but the operation will succeed.