Skip to main content

Restore



Automatic and Manual Restore on Windows

  1. In the AhsayOBM main interface, click the Restore icon.

    success

  2. Select the backup set and destination.

    success

    You can select the temporary directory for storing temporary files by clicking Browse.

    success

    Click Next to proceed.

  3. Select the database(s) you would like to restore.

    For Automatic Restore, select the PostgreSQL node from a specific backup job then select the database(s) that you would like to restore. Click Next to proceed when you are done with the selection.

    success

    For Manual Restore, tick Restore raw file then click Next to proceed.

    success

    LIMITATIONS

    If you would like to restore database to an alternate PostgreSQL server with the Restore raw file option, make sure you have checked the Restore raw file option.

  4. Select to restore the PostgreSQL Databases automatically or select the location path where you would like the raw file(s) to be saved for manual restore:

    success


    Automatic Restore

    Specify the host, port, username and password. The “Verify checksum” setting may also be modified, then click Next to proceed.

    success

    Specify a new name for the database, then click Restore to start the automatic restoration of the database.

    success

    For restore using the original database name, make sure to disconnect the database first before starting the restore process otherwise the restore will fail.

    If the original name and the new name of the database is the same, the original database will be overwritten with the database to be restored and this warning message will be available.

    success

    If there are identical new name for the databases, the restoration will not be allowed to proceed, and this error message will be available.

    success


    Restore Raw File

    Choose the location path where you would like the raw file(s) to be restored to. Click Restore to proceed.

    success

    If you would like to modify the “Verify checksum of in-file delta files during restore” setting, click Show advanced option.

    success

    Verify checksum of in-file delta files during restore

    By enabling this option, the checksum of in-file delta files will be verified during the restore process. This will check the data for errors during the restore process and create a data summary of the in-file delta files which will be included in the report.


  5. Once restoration is finished, “Restore Completed Successfully” will be displayed.

    success

  6. Verify the restore.

    For Automatic Restore

    Using PostgreSQL Command Line Client, you can list the restored databases and tables.

    Example: Listing the databases and tables in the database.

    
    postgres=# \1
    
    	Name 	|
    -------------
    PostgreSQL 1|
    PostgreSQL 2|
    postgres	|
    template0	|
    
    template1	|
    
    (5 rows)
    		
    
    postgres=# \c "PostgreSQL 2"
    You are now connected to database "PostgreSQL 2" as user "postgres".
    PostgreSQL 2=# \dt
    
    		List of relations
    Schema | Name | Type | Owner
    -------+------+------+-------
    public | test | table| postgres
    (1 row)
    		

    For Manual Restore

    Check the location on the local machine to verify the PostgreSQL database files have been restored.

    Example: Using Windows File Explorer

    success


Automatic Restore on Linux

  1. To restore files from your backup destination and automatically apply them to the PostgreSQL server.

    You need to use the Restore.sh script by using a text editor like vi to configure the restore settings like:

    • Backup Set Name -> BACKUP_SET=""
    • Backup Destination -> DESTINATION=""
    • Files/Folders to be Restored -> RESTORE_FROM=""
    • Snapshot to be restored ->POINT_IN_TIME=""
    • Applying the original permission to the restore files ->RESTORE_PERMISSION=""
    • Verifying the in-file delta file checksum ->VERIFY_CHKSUM=””
    • RESTORE_TO=”” settings must be blank
    • To configure the shell script, press Esc + I. You will see this -- INSERT -- on the lower left corner of the terminal.
    • Make sure to disconnect the database first before starting the restoration.
    
    # cd /usr/local/obm/bin
    # vi Restore.sh
    
    # !/bin/sh
    ################################ Restore.sh ##############################
    # You can use this shell script to restore backup files using command-line.#
    # Just customize the "User Define Section" below with values for your #
    # restore action. #
    ############################################################################
    ######################## Start: User Defined Section #####################
    # ----------------------------- BACKUP_SET -------------------------------
    # | The name or ID of the backup set that you want to restore. |
    # | If backup set name is not in English, please use ID instead. |
    # | e.g. BACKUP_SET="1119083740107" |
    # | or BACKUP_SET="FileBackupSet-1" |
    # | |
    # | You can leave this parameter blank if you only have 1 backupset. |
    # --------------------------------------------------------------------------
    BACKUP_SET="PostgreSQL Backup Linux"
    NOTE
    RESTORE_TO=”” settings must be blank
    To configure the shell script, press Esc + I. You will see this -- INSERT -- on the lower left corner of
    the terminal.
    Make sure to disconnect the database first before starting the restoration.
    
    # ------------------------------ DESTINATION ------------------------------
    # | The name or ID of the backup destination that you want to restore from.|
    # | If backup destination name is not in English, please use ID instead. |
    # | e.g. DESTINATION="1740107119083" |
    # | or DESTINATION="Destination-1" |
    # | |
    # | You can leave this parameter blank if you have only 1 destination. |
    # --------------------------------------------------------------------------
    DESTINATION=""
    # ------------------------------- RESTORE_TO -----------------------------
    # | Directory to where you want files to be restored |
    # | set to "" to restore files to original location |
    # | e.g. RESTORE_TO="/tmp" |
    # --------------------------------------------------------------------------
    RESTORE_TO=""
    # ------------------------------ RESTORE_FROM ----------------------------
    # | File/Directory on the backup server that you would like to restore |
    # | e.g. RESTORE_FROM="/Data" |
    # --------------------------------------------------------------------------
    RESTORE_FROM="PostgreSQL"
    # ----------------------------- POINT_IN_TIME ----------------------------
    # | The point-in-time snapshot (successful backup) that you want to restore|
    # | from the backup server. Use "Current" for the latest backup snapshot |
    # | e.g. POINT_IN_TIME="2006-10-04-12-57-13" |
    # | or POINT_IN_TIME="Current" |
    # | |
    # | You can retrieve the point in time by using the ListBackupJob.sh |
    # --------------------------------------------------------------------------
    POINT_IN_TIME="Current"
    # -------------------------- RESTORE_PERMISSION --------------------------
    # | set to "Y" if you want to restore file permissions |
    # | set to "N" if you do NOT want to restore file permissions |
    # --------------------------------------------------------------------------
    RESTORE_PERMISSION="N"
    # ---------------------------- SKIP_INVALID_KEY --------------------------
    # | set to "Y" if you want to skip restore file with invalid key |
    # | set to "N" if you want to prompt user to input a correct key |
    # --------------------------------------------------------------------------
    SKIP_INVALID_KEY="N"
    # ------------------------------ SYNC_OPTION -----------------------------
    # | Delete extra files |
    # | set to "Y" if you want to enable sync option |
    # | set to "N" if you do NOT want to enable sync option |
    # | set to "" to prompt for selection |
    # --------------------------------------------------------------------------
    SYNC_OPTION="N"
    
    # ------------------------- REPLACE_EXISTING_FILE ------------------------
    # | set to "--all" to replace all existing file(s) of the same filename |
    # | set to "--none" to skip all existing file(s) with the same filename |
    # | set to "" to prompt for selection |
    # --------------------------------------------------------------------------
    REPLACE_EXISTING_FILE="--all"
    # ------------------------------ SETTING_HOME ----------------------------
    # | Directory to your setting home. |
    # | Default to ${HOME}/.obm when not set. |
    # | e.g. SETTING_HOME="${HOME}/.obm" |
    # --------------------------------------------------------------------------
    SETTING_HOME=""
    # --------------------------------- FILTER -------------------------------
    # | Filter out what files you want to restore |
    # | -Pattern=xxx-Type=yyy-Target=zzz |
    # | where xxx is the filter pattern, |
    # | yyy is the filter type, whice can be one of the following: |
    # | [exact | exactMatchCase | contains | containsMatchCase| |
    # | startWith | startWithMatchCase | endWith | endWithMatchCase]|
    # | zzz is the filter target, which can be one of the following: |
    # | [toFile | toFileDir | toDir] |
    # | |
    # | e.g. FILTER="-Pattern=.txt-Type=exact-Target=toFile" |
    # --------------------------------------------------------------------------
    FILTER=""
    # -------------------------------- TEMP_DIR ------------------------------
    # | Directory to where you want to store restore files temporarily |
    # | set to "" to use the temporary directory in the backup set |
    # | e.g. TEMP_DIR="/tmp" |
    # --------------------------------------------------------------------------
    TEMP_DIR="/tmp"
    # ----------------------------- VERIFY_CHKSUM ----------------------------
    # | set to "Y" if you want to verify in-file delta file checksum during restore|
    # | set to "N" if you do NOT want to verify in-file delta file checksum during |
    # | restore |
    # --------------------------------------------------------------------------
    VERIFY_CHKSUM="N"
    ######################## END: User Defined Section #######################
    ############################################################################
    # R E T R I E V E A P P _ H O M E P A T H #
    ############################################################################
    
    		
  2. After the Restore.sh script is configured, the files can be restored automatically to the PostgreSQL Server.

    
    # cd /usr/local/obm/bin
    # sh Restore.sh
    Using APP_HOME: : /usr/local/obm
    Using BACKUP_SET : PostgreSQL Backup Linux
    Using RESTORE_FROM : PostgreSQL
    Using RESTORE_TO :
    Using POINT_IN_TIME : Current
    Using RESTORE_PERMISSION : N
    Using TEMP_DIR : /tmp
    Filter Pattern not set, filter would not apply to restore
    [2024-11-07 11:09:09] Start [ AhsayOBM v9.12.2.4 ]
    [2024-11-07 11:09:09] OS: Linux 5.15.0-124-generic (pgsql16-u22); CPU Model:
    VMware-Intel(R) Xeon(R) Gold 5218R CPU @ 2.10GHz (4 processors); Number of
    Cores: 4; Heap Size: 61.2 MB (Current) / 1.8 GB (Maximum); Physical Memory:
    371.6 MB (Free) / 3.8 GB (Total); Process Memory: 296.7 MB (311087104B); OS
    User Identifier: 00-50-56-BF-17-73-root
    [2024-11-07 11:09:09] start,Start [ AhsayOBM v9.12.2.4 ],0,0,0,,0,0
    [2024-11-07 11:09:09] Selected job: 2024-11-07-11-08-57
    [2024-11-07 11:09:09] Selected source: [PostgreSQL]
    [2024-11-07 11:09:09] Info: [followLink=false marshalTargetPath=false
    deleteForSync=false skipFaultKey=false verifyDeltaFileChecksum=false
    ignoreSegmentInfoCorruptedData=true restorePermission=false [RestoreLocation]
    type=ORIGINAL path=[null]]
    [2024-11-07 11:09:09] Backup Set PostgreSQL Backup Linux (1730947292156) -
    AhsayCBS (1730947372064) Using Temporary Directory /temp
    [2024-11-07 11:09:11] [RestoreDownloadManager] Max output concurrent tasks: 2
    [2024-11-07 11:09:11] [RestoreDownloadManager] Max download concurrent tasks: 2
    [2024-11-07 11:09:11] [RestoreDownloadManager] Max restore file wait time:
    86400000ms
    [2024-11-07 11:09:11] [RestoreDownloadManager] Max cached random access file
    handles: 2048
    [2024-11-07 11:09:11] [RestoreCacheManager] Cache Info Mem MaxUsage: 1000
    (1000)
    [2024-11-07 11:09:11] [RestoreCacheManager] Cache Info Mem ResetThreshold: 999
    (999)
    [2024-11-07 11:09:11] [RestoreCacheManager] Cache Data Mem MaxUsage: 134217728
    (128 M)
    [2024-11-07 11:09:11] [RestoreCacheManager] Cache Data Mem ResetThreshold:
    134217727 (128 M)
    [2024-11-07 11:09:11] [RestoreCacheManager] Cache Data Disk MaxUsage:
    4587163648 (4.27 G)
    [2024-11-07 11:09:11] [RestoreCacheManager] Cache Data Disk ResetThreshold:
    4587163647 (4.27 G)
    [2024-11-07 11:09:11] [RestoreCacheManager] Cache Booster Setting: 1024 (768)
    [2024-11-07 11:09:11] Creating new directory...
    "/temp/RestoreSet/1730947292156/RestoreDatabase/PostgreSQL"
    [2024-11-07 11:09:11] Downloading...
    "/temp/RestoreSet/1730947292156/RestoreDatabase/PostgreSQL/db_500mb.sql" (Total
    423.35 M bytes)
    [2024-11-07 11:09:21]
    "/temp/RestoreSet/1730947292156/RestoreDatabase/PostgreSQL/db_500mb.sql"
    (423.35 M bytes) downloaded
    [2024-11-07 11:09:21] Start restore files to PostgreSQL Server... "db_500mb"
    
    [2024-11-07 11:09:21]
    file,/temp/RestoreSet/1730947292156/RestoreDatabase/PostgreSQL/db_500mb.sql,346
    46672,443915452,1730948702609,,1730948951741,1730948961033
    [2024-11-07 11:09:21] [PostgreSQLBackupMgr.initDatabase] Dropping and Creating:
    db_500mb
    [2024-11-07 11:09:21] Restoring to PostgreSQL Server Database... "db_500mb"
    [2024-11-07 11:09:30] End restore files to PostgreSQL Server... "db_500mb"
    [2024-11-07 11:09:32] [RestoreManager-984978888] Num of request(s): 0 (f = 0, m
    = 0/0, a = N/A )
    [2024-11-07 11:09:32] [RestoreCacheManager-593881656] Num of download task(s):
    2 (mc = 1, v2 = 0)
    [2024-11-07 11:09:32] [RestoreCacheManager-593881656] Num of swap cache(s): 0
    (m = 0, f = 0)
    [2024-11-07 11:09:32] [RestoreCacheManager-593881656] <Cache-Info>
    [2024-11-07 11:09:32] [RestoreCacheManager-593881656] -tmpTBL-
    [MemCc@ChunkInfoRow-1490297742] Summary > NONE
    [2024-11-07 11:09:32] [RestoreCacheManager-593881656] -tmpTBL-
    [FilCc@ChunkInfoRow-339734447] Summary > NONE
    [2024-11-07 11:09:32] [RestoreCacheManager-593881656] <Cache-Data>
    [2024-11-07 11:09:32] [RestoreCacheManager-593881656] -tmpTBL-
    [MemCc@ChunkDataRow-592238700] Summary > NONE
    [2024-11-07 11:09:32] [RestoreCacheManager-593881656] -tmpTBL-
    [FilCc@ChunkDataRow-700171836] Summary > NONE
    [2024-11-07 11:09:32] [Runtime] Time0=1730948964822, Count0=15,
    Time1=1730948951819, ZCount1=3, NZCount1=26, Init1=15291888, Last1=946208,
    Min1=946208, Max1=79639024, MinUC1=3, MaxUC1=6
    [2024-11-07 11:09:32] [Overall] Time0=0, Count0=0, Time1=1730948951819,
    ZCount1=2, NZCount1=42, Init1=335720, Last1=109113696, Min1=335720,
    Max1=161619688, MinUC1=0, MaxUC1=14
    [2024-11-07 11:09:32] Total Downloaded Size = 66.08 MB
    [2024-11-07 11:09:32] Total Restored Size = 423.35 MB
    [2024-11-07 11:09:32] Total Restored File = 1
    [2024-11-07 11:09:32] Restore Completed Successfully
    [2024-11-07 11:09:32] end,RESTORE_STOP_SUCCESS,0,0,0,,0,0
    		

Manual Restore on Linux

To restore files that have been backed up from your backup destination, you need to use the Restore.sh script by using a text editor like vi to configure the restore settings like:

  • Backup Set Name -> BACKUP_SET=""
  • Backup Destination -> DESTINATION=""
  • Location of Restored Files ->RESTORE_TO=""
  • Files/Folders to be Restored -> RESTORE_FROM=""
  • Snapshot to be restored ->POINT_IN_TIME=""
  • Applying the original permission to the restore files ->RESTORE_PERMISSION=""
  • Verifying the in-file delta file checksum ->VERIFY_CHKSUM=””

# cd /usr/local/obm/bin
# sh Restore.sh
Using APP_HOME: : /usr/local/obm
Using BACKUP_SET : PostgreSQL Backup Linux
Using RESTORE_FROM : PostgreSQL
Using RESTORE_TO : /restored
Using POINT_IN_TIME : Current
Using RESTORE_PERMISSION : N
Using TEMP_DIR : /temp
Filter Pattern not set, filter would not apply to restore
[2024-11-07 11:15:42] Start [ AhsayOBM v9.12.2.4 ]
[2024-11-07 11:15:42] OS: Linux 5.15.0-124-generic (pgsql16-u22); CPU Model:
VMware-Intel(R) Xeon(R) Gold 5218R CPU @ 2.10GHz (4 processors); Number of Cores:
4; Heap Size: 49 MB (Current) / 1.8 GB (Maximum); Physical Memory: 724.1 MB (Free)
/ 3.8 GB (Total); Process Memory: 300.8 MB (315453440B); OS User Identifier: 00-50-
56-BF-17-73-root
[2024-11-07 11:15:42] start,Start [ AhsayOBM v9.12.2.4 ],0,0,0,,0,0
[2024-11-07 11:15:42] Selected job: 2024-11-07-11-15-30
[2024-11-07 11:15:42] Selected source: [PostgreSQL]
[2024-11-07 11:15:42] Info: [followLink=false marshalTargetPath=false
deleteForSync=false skipFaultKey=false verifyDeltaFileChecksum=false
ignoreSegmentInfoCorruptedData=true restorePermission=false [RestoreLocation]
type=RAW path=[/restored]]
[2024-11-07 11:15:42] Backup Set PostgreSQL Backup Linux (1730947292156) - AhsayCBS
(1730947372064) Using Temporary Directory /temp
[2024-11-07 11:15:44] [RestoreDownloadManager] Max output concurrent tasks: 2
[2024-11-07 11:15:44] [RestoreDownloadManager] Max download concurrent tasks: 2
[2024-11-07 11:15:44] [RestoreDownloadManager] Max restore file wait time:
86400000ms
[2024-11-07 11:15:44] [RestoreDownloadManager] Max cached random access file
handles: 2048
[2024-11-07 11:15:44] [RestoreCacheManager] Cache Info Mem MaxUsage: 1000 (1000)
[2024-11-07 11:15:44] [RestoreCacheManager] Cache Info Mem ResetThreshold: 999
(999)

[2024-11-07 11:15:44] [RestoreCacheManager] Cache Data Mem MaxUsage: 134217728 (128
M)
[2024-11-07 11:15:44] [RestoreCacheManager] Cache Data Mem ResetThreshold:
134217727 (128 M)
[2024-11-07 11:15:44] [RestoreCacheManager] Cache Data Disk MaxUsage: 4587169792
(4.27 G)
[2024-11-07 11:15:44] [RestoreCacheManager] Cache Data Disk ResetThreshold:
4587169791 (4.27 G)
[2024-11-07 11:15:44] [RestoreCacheManager] Cache Booster Setting: 1024 (768)
[2024-11-07 11:15:44] Creating new directory... "/restored/PostgreSQL"
[2024-11-07 11:15:44] Downloading... "/restored/PostgreSQL/db_500mb.sql" (Total
423.35 M bytes)
[2024-11-07 11:15:47] "/restored/PostgreSQL/db_500mb.sql" (423.35 M bytes)
downloaded
[2024-11-07 11:15:47]
file,/restored/PostgreSQL/db_500mb.sql,34646672,443915452,1730948702609,,1730949344
397,1730949347201
[2024-11-07 11:15:48] [RestoreManager-1178270318] Num of request(s): 0 (f = 0, m =
0/0, a = N/A )
[2024-11-07 11:15:49] [RestoreCacheManager-1519927539] Num of download task(s): 2
(mc = 1, v2 = 0)
[2024-11-07 11:15:49] [RestoreCacheManager-1519927539] Num of swap cache(s): 0 (m =
0, f = 0)
[2024-11-07 11:15:49] [RestoreCacheManager-1519927539] <Cache-Info>
[2024-11-07 11:15:49] [RestoreCacheManager-1519927539] -tmpTBL-
[MemCc@ChunkInfoRow-1227612217] Summary > NONE
[2024-11-07 11:15:49] [RestoreCacheManager-1519927539] -tmpTBL-
[FilCc@ChunkInfoRow-1834961152] Summary > NONE
[2024-11-07 11:15:49] [RestoreCacheManager-1519927539] <Cache-Data>
[2024-11-07 11:15:49] [RestoreCacheManager-1519927539] -tmpTBL-
[MemCc@ChunkDataRow-1971855969] Summary > NONE
[2024-11-07 11:15:49] [RestoreCacheManager-1519927539] -tmpTBL-
[FilCc@ChunkDataRow-5181771] Summary > NONE
[2024-11-07 11:15:49] [Runtime] Time0=0, Count0=0, Time1=1730949344522, ZCount1=3,
NZCount1=9, Init1=44677616, Last1=122111792, Min1=44677616, Max1=177450368,
MinUC1=0, MaxUC1=5
[2024-11-07 11:15:49] [Overall] Time0=0, Count0=0, Time1=1730949344522, ZCount1=2,
NZCount1=10, Init1=7697488, Last1=218691024, Min1=7697488, Max1=228351568,
MinUC1=0, MaxUC1=6
[2024-11-07 11:15:49] Total Downloaded Size = 66.08 MB
[2024-11-07 11:15:49] Total Restored Size = 423.35 MB
[2024-11-07 11:15:49] Total Restored File = 1
[2024-11-07 11:15:49] Restore Completed Successfully
[2024-11-07 11:15:49] end,RESTORE_STOP_SUCCESS,0,0,0,,0,0

Verify the files are restored on the machine.


# ls -la /restores/PostgreSQL

total 433524
drwxr-xr-x 2 root root 4096 Nov 7 11:15 .
drwxr-xr-x 3 root root 4096 Nov 7 11:15 ..
-rw-r--r-- 1 root root 443915452 Nov 7 11:15 db_500ml.sql