Maintenance of the LinkAhead Server#
Note
This page has been migrated from the old documentation, and has not yet been fully revised. There might be inconsistencies or errors when using with current LinkAhead versions.
Creating a Backup#
In order to create a full backup of LinkAhead, the state of the SQL-Backend (MySQL, MariaDB) has to be saved and the internal file system of LinkAhead (symbolic links to file systems that are mounted and uploaded files) has to be saved.
You can find the documentation on how to back up the SQL-Backend in the Backup documentation.
In order to save the file backend we recommend to tar the file system. However, you could use other
backup methods that allow to restore the file system. The LinkAhead internal file system is located
at the path defined by the FILE_SYSTEM_ROOT configuration variable (
see configuration).
The command could look like:
tar czvf /path/to/new/backup /path/to/caosdb/filesystem.tar.gz
You can also save the content of LinkAhead using XML. This is not recommended since it produces less reproducible results than a plain SQL backup. However, there may be cases in which an XML backup is necessary, e.g., when transferring entities between two different LinkAhead instances.
Collect the entities that you want to export in a
Container, named cont here. Then you can
export the XML with:
from caosadvancedtools.export_related import invert_ids
from lxml import etree
invert_ids(cont)
xml = etree.tounicode(cont.to_xml(
local_serialization=True), pretty_print=True)
with open("caosdb_data.xml"), "w") as fi:
fi.write(xml)
Restoring a Backup#
Warning
LinkAhead should be offline before restoring data.
If you want to restore the internal file system, simply replace it. E.g. if your backup is a tarball:
tar xvf /path/to/caosroot.tar.gz
You find the documentation on how to restore the data in the SQL-Backend Backup documentation
If you want to restore the entities exported to XML, you can do:
cont = db.Container()
with open("caosdb_data.xml") as fi:
cont = cont.from_xml(fi.read())
cont.insert()