ybrestore Examples

This section contains some simple examples of restore commands, using different options.

Restore an existing database under a new name

This example restores a database to the same system under a different name. Here is a breakdown of the ybrestore command options used in this example:
Command Syntax Explanation
ybrestore Call the ybrestore tool on the client.
-W Prompt for the user's password.
--username yb100 Run as user yb100 (must be a superuser).
-d premdb_restored Restore the database under the name premdb_restored. (You cannot use the name of the source database in the command unless it has been dropped from the target system or does not exist on the target system.)
--point October15Inc3 Identify the restore point, which must be a valid backup name for the database you want to restore: October15Inc3 in this case.
--chain October2019 Name the backup chain October2019.
/home/brumsby/premdb_daily_backups Identify the location of the backup files, as specified when the ybbackup command was run. If the backup used multiple directories, make sure you name the first backup directory in the ybrestore command. This directory contains the metadata files (metaDB.*) for the backup. (You do not need to list the other directories.)
Tip: You can run the ybbackupctl --list command to verify backup information before running a restore command. See ybbackupctl Examples.
Here is the command line and the full output of the restore operation, which uses a sequence of four backups:
$ ybrestore -W --username yb100 -d premdb_restored --point October15Inc3 --chain October2019 /home/brumsby/premdb_daily_backups
Password for user yb100: 
17:44:56.066 [ INFO] ABOUT CLIENT:
    app.cli_args         = "-W" "--username" "yb100" "-d" "premdb_restored" "--point" "October15Inc3" "--chain" "October2019" "/home/brumsby/premdb_daily_backups"
    app.name_and_version = "Yellowbrick Backup and Restore version 4.0.0-1385"
    java.home            = "/usr/lib/jvm/java-8-oracle/jre"
    java.version         = "1.8.0_101"
    jvm.memory           = "512.00 MB (max=4.00 GB)"
    jvm.name_and_version = "Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)"
    jvm.options          = "-Xms512m, -Xmx4g, -XX:+UseG1GC, -Dapp.name=ybrestore2, -Dapp.pid=4240, -Dapp.repo=/opt/ybtools/lib, -Dapp.home=/opt/ybtools, -Dbasedir=/opt/ybtools"
    jvm.vendor           = "Oracle Corporation"
    os.name_and_version  = "Linux 4.4.0-31-generic (amd64)"

17:44:56.067 [ INFO] Running restore using input locations: [file:/home/brumsby/premdb_daily_backups/]
17:44:57.407 [ INFO] RestoreSession: Found candidate for restore : October15Inc3
17:44:57.585 [ INFO] Calculated restore sequence: 
17:44:57.585 [ INFO] 	1) October15Full
17:44:57.586 [ INFO] 	2) October15Inc1
17:44:57.586 [ INFO] 	3) October15Inc2
17:44:57.586 [ INFO] 	4) October15Inc3
17:44:57.947 [ INFO] Starting restore of 'October15Full' [15468]
ybrestore_meta | 100.0% |        Read: 21.00 KiB / 21.00 KiB        |      Write: 21509       |  0.00 B/s   |   2019-10-15 17:44:58  

ybrestore_data | 100.0% |       Read: 284.73 KiB / 284.73 KiB       |    Write: 284.59 KiB    | 28.10 KB/s  |   2019-10-15 17:45:14  
17:45:14.012 [ INFO] Validating restored objects
17:45:14.012 [ INFO] Committing
17:45:14.025 [ INFO] Completed restore of 'October15Full'

17:45:14.089 [ INFO] Starting restore of 'October15Inc1' [15767]
ybrestore_meta | 100.0% |         Read: 6.56 KiB / 6.56 KiB         |       Write: 6713       |  9.53 KB/s  |   2019-10-15 17:45:14  

ybrestore_data | 100.0% |         Read: 7.98 MiB / 7.98 MiB         |     Write: 7.97 MiB     |  1.58 MB/s  |   2019-10-15 17:45:17  
17:45:17.991 [ INFO] Validating restored objects
17:45:17.991 [ INFO] Committing
17:45:18.001 [ INFO] Completed restore of 'October15Inc1'

17:45:18.064 [ INFO] Starting restore of 'October15Inc2' [15828]
ybrestore_meta | 100.0% |         Read: 1.95 KiB / 1.95 KiB         |       Write: 2000       |  5.28 KB/s  |   2019-10-15 17:45:18  

ybrestore_data | 100.0% |       Read: 225.88 MiB / 225.88 MiB       |    Write: 225.82 MiB    | 32.21 MB/s  |   2019-10-15 17:45:24  
17:45:24.575 [ INFO] Validating restored objects
17:45:24.575 [ INFO] Committing
17:45:24.602 [ INFO] Completed restore of 'October15Inc2'

17:45:24.664 [ INFO] Starting restore of 'October15Inc3' [15888]
ybrestore_meta | 100.0% |         Read: 1.94 KiB / 1.94 KiB         |       Write: 1991       |  5.40 KB/s  |   2019-10-15 17:45:25  

ybrestore_data | 100.0% |        Read: 34.64 MiB / 34.64 MiB        |    Write: 34.64 MiB     |  8.64 MB/s  |   2019-10-15 17:45:27  
17:45:27.665 [ INFO] Validating restored objects
17:45:27.665 [ INFO] Committing
17:45:27.678 [ INFO] Completed restore of 'October15Inc3'

17:45:27.690 [ INFO] Done

Restore a database with users, roles, grants, and ACLs

The following command restores a database with --security-mode all. Therefore, security-related objects and privileges are preserved.
$ ybrestore -W --username yb100 -d premdb_restored --point Dec18Full --chain December2019 
--security-mode all /home/brumsby/premdb_daily_backups
Password for user yb100: 
...

For details, see Restoring Users and Roles.

Attempt an incremental restore that is not needed

This example attempts an incremental restore, but the system detects that the target database is already in sync with the changes in the specified backup point.
$ ybrestore -W --username yb100 -d premdb_restored --all-security --point October15Inc3 --chain October2019 /home/brumsby/premdb_daily_backups
Password for user yb100: 
16:49:11.963 [ INFO] ABOUT CLIENT:
...
16:49:11.965 [ INFO] Running restore using input locations: [file:/home/brumsby/premdb_daily_backups/]
16:49:13.338 [ INFO] RestoreSession: Found candidate for restore : October15Inc3
16:49:13.498 [ INFO] RestoreSession - Last Backup Snapshot = October15Inc3
16:49:13.498 [ INFO] RestoreSession: Nothing to restore as desired snapshot 'October15Inc3' is already applied to YBD
16:49:13.498 [ INFO] System is up to date

Restore a database and disable HOT_STANDBY mode

Note the use of the --hot-standby off option in this example. When the restore completes, the database is not kept in HOT_STANDBY mode. Therefore, it cannot be used for incremental restores.
$ ybrestore -W --username yb100 -d premdb_restored --point Oct23Full --chain October2019 
/home/brumsby/premdb_daily_backups --hot-standby off
Password for user yb100: 
...
17:32:27.836 [ INFO] Running restore using input locations: [file:///home/brumsby/premdb_daily_backups/]
17:32:29.637 [ INFO] RestoreSession: Found candidate for restore : Oct23Full
17:32:29.786 [ INFO] Calculated restore sequence: 
17:32:29.787 [ INFO] 	1) Oct23Full
17:32:30.123 [ INFO] Starting restore of 'Oct23Full' [10880]
...
17:33:05.370 [ INFO] Completed restore of 'Oct23Full'

17:33:05.371 [ INFO] Disabling hot standby mode
17:33:05.374 [ INFO] Disabled hot standby mode
17:33:05.391 [ INFO] Done

Attempt an incremental restore to a database that is not in hot_standby mode

This example attempts to run an incremental restore on a database that has been taken out of HOT_STANDBY mode. Therefore, the restore fails.
$ ybrestore -W --username yb100 -d premdb_restored --point October16Inc4 --chain October2019 /home/brumsby/premdb_daily_backups
Password for user yb100: 
18:45:18.752 [ INFO] ABOUT CLIENT:
...
18:45:18.754 [ INFO] Running restore using input locations: [file:/home/brumsby/premdb_daily_backups/]
18:45:20.198 [ INFO] RestoreSession: Found candidate for restore : October16Inc4
18:45:20.347 [ INFO] RestoreSession - Last Backup Snapshot = October16Inc3
18:45:20.347 [ INFO] Calculated restore sequence: 
18:45:20.347 [ INFO] 	1) October16Inc4
18:45:20.444 [ERROR] Failed: Error starting restore session  CAUSED BY: Target database premdb_restored isn't a hot standby