Files
raven/docs/8.0/ayanova/docs/ops-restore.md
2022-03-27 19:38:40 +00:00

7.6 KiB

Restore from backup

Restoring an AyaNova backup is done manually through the operating system.

A full AyaNova backup consists of:

  1. A database backup file identified by name which starts with "db-" followed by a timestamp and ends with ".backup"
  2. An attachments backup file which contains all files attached to objects within AyaNova and can be identified by name which starts with "at-" followed by a timestamp and ends with ".zip" as it is a standard zip format archive. Attachement files are NOT stored in their original name and are identified from the database so it is important that a database backup and attachment backup be restored together as a matched pair or there is a chance of losing the connection between attachment files and the AyaNova objects to which they are attached.

What will be restored

The AyaNova license key and all user entered data are stored in the AyaNova database. All attached files are stored in the attachments folder in many sub folders. The restoration process will restore all data entered in AyaNova to the point in time that the backup was taken. There is no need to separately install or backup a license, as long as the database is backed up, the license is also backed up.

Restore steps

New AyaNova server installation

If this is a restoration to a new computer that doesn't have AyaNova installed and confirmed running; then the first step is to install AyaNova

It must be started and confirmed to be operating correctly before proceeded to the next step to ensure it's working and also so it can create the AyaNova database in PostgreSQL server correctly so it can be restored to later.

PostgreSQL restore process requires the database to be present before restoring to it

Once the AyaNova server is running and has created a database it must be shut down before proceeding.

Shut down the AyaNova server

AyaNova "Server" installation with standalone PostgreSQL server

For all "Server" installations of AyaNova with a separate standalone PostgreSQL server; stop the AyaNova server but do not stop the PostgreSQL server.

Windows standalone "single" type installation

If this is a single standalone Windows installation configuration that starts a self contained database server, the self-contained PostgreSQL server is stopped automatically when the AyaNova server is stopped so PostgreSQL will need to be started manually from a command prompt in order to restore data to it.

Stop the AyaNova server first then start PostgreSQL from a command prompt.

If the default values were used during installation the command will be:

"C:/Program Files/ayanova/local-postgres/bin/postgres.exe"  -D "C:/ProgramData/ayanova/database" -p 5432

Be sure to include the quotation marks exactly as written.

PostgreSQL will display database system is ready to accept connections indicating it's up and running and ready for restore. Do not stop PostgreSQL until directed to do so after restore below.

Make a copy of the AyaNova server's data folder

If there is any existing data then a file system copy of any existing AyaNova server's data folders to a safe location should be done first as a precaution.

Restoring data will wipe out any existing data and mistakes can happen.

If you have used the default configuration all data will be stored in sub-folders under the single folder specified in the AYANOVA_DATA_PATH. If you have split them out into individually specified locations then be sure to make copies of each of them before proceeding with restoration.

The location of these folders is also logged on server startup in the server log and also can be viewed in the AyaNova user interface on the server information page.

Restore the attachments

  1. Identify the attachments data folder location. Check the server configuration and identify the location of the attachment files. There are two ways this can be specified, either directly through the AYANOVA_ATTACHMENT_FILES_PATH setting or indirectly through the AYANOVA_DATA_PATH setting in which case the attachments folder will be found in a folder called attachments inside the folder specified by the AYANOVA_DATA_PATH setting.

  2. Erase the current contents of the attachments folder identifed above, it must be completely empty before the next step. Note: you do not need to erase any other folders that may also be in the data folder such as logs, backup or temp, only the attachments folder contents need to be erased

  3. Unzip the contents of the attachments zip file into the attachments folder. There will be a lot of folders with single letter of digit names contained within each other, this is normal, you will not see recognizable file names here. Be careful to ensure you are unzipping into the attachments folder and not a sub folder, it's easy to accidentally unzip a higher level directory into the intended directory in which case you won't see any of your attachments in AyaNova until this is resolved.

Restore the database

Use the PostgreSQL pg_restore utility to restore the database backup file to an existing AyaNova database.

If you do not have an existing AyaNova database to restore to, the AyaNova server will create one for you; start the AyaNova server, allow it to create an empty db then shut it down again to restore.

The PostgreSQL utility pg_restore is used to restore the .backup file containing the database backup from AyaNova.

The command format is: pg_restore -U postgres -c [PATH_TO_THE_AYANOVA_BACKUP_FILE_TO_BE_RESTORED.backup]

Run the restore command from the console substituting your backup file path in the examples below:

Windows server:

pg_restore -U postgres -c -d AyaNova "C:\temp\db-20211212195504569.backup"

Windows self contained "single" user installation:

"C:/Program Files/ayanova/local-postgres/bin/pg_restore" -U postgres -c -d AyaNova "C:\temp\db-20211212195504569.backup"

Linux server:

pg_restore -U postgres -c -d AyaNova ~/downloads/db-20211212195504569.backup

The restore will complete normally without any message if successful.

AyaNova can be re-started at this point, for server type installations restart through the IIS 'site' in Windows or the Service in Linux. If using the desktop single Windows installation, stop the PostgreSQL started in the earlier restore step by typing ctrl-c in the PostgreSQL console window then start AyaNova from the desktop launcher as normally.

Verify the data

  1. Verify database: login to AyaNova, check that the most recent data that should be in the database backup is present
  2. Verify attachments: First examine the list of attachments that AyaNova knows about in the database by opening the Adminstration -> Attached files. This list shows the attachments that AyaNova expects not necessarily what is physically present so select an attachment listed to open the record that attachment is connected to and confirm the physical file is actually present by opening the file in the attachments area of the form. If the file won't open verify that the attachment files are restored to the attachments folder where AyaNova expects to find them and not in another folder or sub folder and check again and also verify it's not just an issue with that one attachment by checking or more other attachment files in the same way.

There is no need to shut down the server if the attachment files need to be moved to the correct folder.