# Database Management
# Migrating an existing database (Linux)
- 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"
Copy the backup file to the target VM.
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)
- 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
Copy the backup file to the target VM.
Stop the FileMage Gateway service in the Windows service manager on the target VM.
Run the following command on the target VM.
"C:\Program Files\PostgreSQL\12\bin\pg_restore" -d filemage -U postgres --clean filemage_db.backup
- 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.