Backup a Private Cloud Server and restore PostgreSQL databases - x360Sync

Written By Tami Sutcliffe (Super Administrator)

Updated at June 26th, 2023

Create a database backup using pg_dump.exe

1. Open an elevated CMD prompt. 

2. Change the directory to the bin folder in your PostgreSQL installation path (i.e. C:\PostgreSQL 9.1\bin)

3. Find the postgres password. (This can be found in the [portal] section of "\x360Sync Server\conf\config.ini")

4. Create a dump of the portal database with the following command

pg_dump.exe -U postgres -Fc portal > YOUR_DB_BACKUP_FILENAME

Example: pg_dump.exe -U postgres -Fc portal > c:\backup\db_backup.bak

This could be automated with a script similar to following:
-------------------------------------------------------------
@echo off

   for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (

     set dow=%%i

     set month=%%j

     set day=%%k

     set year=%%l

   )

   set datestr=%month%_%day%_%year%

   echo datestr is %datestr%

set BACKUP_FILE=portal_%datestr%.bak

echo backup file name is %BACKUP_FILE%


SET PGPASSWORD=<password>


d:\PostgreSQL9.1\bin\pg_dump -U postgres -Fc -f d:\DB_Backup\%BACKUP_FILE% portal

 
REM Remove backups older than 30 days

forfiles /p "d:\DB_Backup" /s /m * /d -30 /c "cmd /c del @path"
--------------------------------------------------------------------

Restore a database backup using pg_dump.exe

This method assumes total loss of the x360Sync Server, with restoration to a new system.

Begin by going through the steps in this document, but ignore the PostgreSQL directions, as the previous PostgreSQL database/installation is considered to be lost in this scenario: 

Migrate the system to a new server - x360Sync

This information explains how to how to perform a system migration. Please note, however, that it is important to first contact Support so that they can assist with this process.

1. Follow the other steps of the article to reinstall the x360Sync Server. It will be installed using a fresh blank copy of the portal database.

2. Once the installation finishes, stop the following services in services.msc

  • x360Sync Celery
  • x360Sync Server
  • Apache24
  • Redis

3. Remove the freshly created portal database.

  • Open \PostgreSQL9.1\bin\pgadmin3.exe
  • Double Click on the server (localhost:5432) and when prompted, enter the password (can be found in the [portal] section of "\x360Sync Server\conf\config.ini")
  • Expand "Databases"
  • Right-click on the portal database and choose "Delete/Drop" and confirm any dialog boxes that prompt 

4. Restore the database from your backup file.

For ease of use, copy your backup file into the PostgreSQL bin folder (i.e. C:\PostgreSQL9.1\bin)

5. Open an elevated CMD prompt.

6. Change the directory to the bin folder in your PostgreSQL installation path (i.e. C:\PostgreSQL9.1\bin)

7. Find the postgres password. (This can be found in the [portal] section of "\x360Sync Server\conf\config.ini")

8. Restore the database using pg_restore.exe pg_restore -d postgres -u postgres -h localhost -p 5432 -Fc -C YOUR_DB_BACKUP_FILENAME

Enter the postgres password when prompted


Restore a database back to same system

The method to restore on the same system could be done using the same commands with some changes.

1. Backup the following directories to retain your SSL implementations for Apache and x360Sync . These would be copied back per the migration instructions here: Migrate the system to a new server - x360Sync

C:\Apache24\conf\*

C:\x360Sync Server\conf\*

2. Open Add/remove Programs

  • Uninstall x360Sync Server
  • Uninstall PostgreSQL 9.1

3. Follow the instructions in the above scenario to reinstall the x360Sync Server and restore the database. 

 

 

 


SUPPORT | 720-204-4500 | 800-352-0248

1532