Cisco Optical Network Planner Configuration Guide, Releases 26.x.x

PDF

Restore the database manually

Want to summarize with AI?

Log in

Overview

Restore a database on your system after removing related Docker services.

This task is for recovering your database using a backup archive after you remove conflicting Docker services. You may need to do this if the database becomes corrupt or you wish to revert to a previous state.

Procedure

1.

Check the Cisco ONP database.

Example:

$ postgres CnpDB
MongoDB shell version: 2.6.10
 connecting to: CnpDB
 Server has startup warnings: 
 2019-01-31T12:17:39.354+0000 I STORAGE [initandlisten] 
 2019-01-31T12:17:39.354+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine.
 2019-01-31T12:17:39.354+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
 2019-01-31T12:17:40.013+0000 I CONTROL [initandlisten] 
 2019-01-31T12:17:40.013+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
 2019-01-31T12:17:40.013+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
 2019-01-31T12:17:40.013+0000 I CONTROL [initandlisten] 
 > show collections
 NetworkEntity
 SystemLog
 BOM
 fs.files
 Users
 fs.chunks
 ErrorInfo
 NetworkObject
 UserGroups
 TaskInfo
 ActionGroups
 Roles
 > 
 ```
2.

Remove the Cisco ONP back-end and front-end Docker services,"docker service rm cnp_cnp cnp_cnp_frontend" and check again:

Example:

```
$ postgres CnpDB
 MongoDB shell version: 2.6.10
 connecting to: CnpDB
 Server has startup warnings: 
 2019-01-31T12:17:39.354+0000 I STORAGE [initandlisten] 
 2019-01-31T12:17:39.354+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS file system is strongly recommended with the WiredTiger storage engine.
 2019-01-31T12:17:39.354+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
 2019-01-31T12:17:40.013+0000 I CONTROL [initandlisten] 
 2019-01-31T12:17:40.013+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
 2019-01-31T12:17:40.013+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
 2019-01-31T12:17:40.013+0000 I CONTROL [initandlisten] 
 > show collections
 > 
 ```
3.

Copy the database to the folder that is mapped to PostgresDB container's volume:

Example:

 $ sudo cp backups/2019-02-01-04-29.archive /var/lib/postgresdb_cnp/
4.

Restore the database and check.

Example:

 $ docker exec -t cnp_postgres.1.$(docker service ps -f 'name=cnp_postgres.1' -f 'desired-state=running' cnp_postgres -q) bash -c "postgresrestore -u \$(cat \$MONGO_INITDB_ROOT_USERNAME_FILE) -p \$(cat \$MONGO_INITDB_ROOT_PASSWORD_FILE) --authenticationDatabase admin --port 27017 -h localhost --db CnpDB --gzip --archive=/data/db/2019-02-01-04-29.archive"

The database is restored from the backup archive file and service access is enabled as appropriate.


Restore the database using a script

Perform a database restoration using a backup file and a shell script.

You can restore the database using a script, which is available at this location:

/ONP/Images/restore_postgres.sh

Follow these steps to restore the database using a script:

Procedure

Use the command sudo bash restore_postgres.sh to restore the database

Example:

 $ sudo bash restore_postgres.sh DB backup archive file path.
$ sudo bash restore_postgres.sh /backups/backup.daily/2019-05-05-23-58.archive
The database backup is created and a confirmation prompt appears asking to delete the database.
!!! WARNING! Complete Restore Operation will replace Existing Database with Backup Database (Recommended) !!!
Do you want Complete Restore? (Yes/No) [default - Yes]

Enter Yes to delete the database and restore the database with backup file.

Enter No to not delete the database and apply only missing data(s) from backup file.

The database is restored from the backup archive according to your prompt selection. You receive a confirmation indicating that the restore operation is complete.


Syntax to schedule the backup using Crontab

Crontab allows you to schedule backups by specifying a set of time and date fields. Use the following syntax in your Crontab file to define when the backup occurs:

m h dom mon dow

Where:

  • m: Minutes (0-59)

  • h: Hours (1-23)

  • dom: Day of the month (1-31)

  • mon: Month of the year (1-12)

  • dow: Day of the week (0-6, where 0 represents Sunday)

To specify the time, you can provide exact values for the minute (m), hour (h), day of the month (dom), month (mon), and day of the week (dow); alternatively, you can use the wildcard character * in these fields to indicate "any value."

Note

The backup jobs are initiated according to the system daemon's understanding of time and time zones as defined by the cron scheduler.