Restore from backup¶
Restoring an AyaNova backup is done manually through the operating system.
A full AyaNova backup consists of:
- A database backup file identified by name which starts with "db-" followed by a timestamp and ends with ".backup"
- 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.
Can I restore to a different operating system?¶
Yes! AyaNova database and attachment backups are compatible between Linux and Windows in either direction. This is a convenient way to switch operating systems or to move AyaNova from a "Perpetual" licensed self-hosted to a "Subscription" licensed hosted AyaNova as a service (or vice versa).
Restore steps¶
AyaNova subscription server¶
The instructions below are for self-hosted AyaNova "Perpetual" licensed installations.
If you are using our AyaNova subscription service and need to restore a backup you have previously downloaded our support department will take care of that for you.
Reminder that we do not keep separate copies of your backup, we can only restore a backup if you are able to provide it to us or there is a copy available on your server
Contact AyaNova support and we will initiate the restore process for you using a copy of the backup on your server or a if you have a backup set downloaded you would like to restore, support will provide instructions on how to upload your backup to us so we can restore it to your server.
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.
Linux server¶
If you followed the installation instructions in this guide to run AyaNova as a service then AyaNova is stopped with the following command:
Windows IIS¶
If hosting AyaNova through IIS use the IIS Manager user interface to stop the AyaNova website which will in turn stop the AyaNova 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¶
-
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. -
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
-
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 a command prompt substituting your backup file path in the examples below:
Windows server:
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"
Windows Powershell terminal with quoted path:
Powershell needs an ampersand character at the start of a quoted path to a command to correctly interpret the input as a command:
& "C:/Program Files/ayanova/local-postgres/bin/pg_restore" -U postgres -c -d AyaNova "C:\temp\db-20211212195504569.backup"
Linux server:
The database backup file must be placed in a location that the 'postgres' user has permission to read from.
On a default Linux Postgres installation a suitable folder is:
/var/lib/postgresql
Copy your db-xxxxxxx.backup
file to that location before issuing the restore command.
The restore will complete normally without any message if successful.
Linux server only - set ownershipt and permissions¶
Before restarting the AyaNova server on Linux it will first be necessary to reset the ownership and permissions for the files and folders or AyaNova will not be able to write it's log, access attachments or generate reports properly.
Repeat the Linux server installation instruction step Set ownership and permissions before proceeding to the next step and restarting the AyaNova server.
Restart AyaNova server¶
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 window then start AyaNova from the desktop launcher as normally.
Verify the data¶
- Verify database: login to AyaNova, check that the most recent data that should be in the database backup is present
- 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.
Cleanup¶
Once data is verified and attachments are confirmed don't forget to cleanup any temporary copies made of the Data folders and any copies of the backup or zip files to maintain security, save space and ensure no confusion in future if it becomes necessary to restore again.