Backup and Restore
1 2018-08-27T19:19:06+00:00 Peter Cobb 29b5ca8528741ed24b5845551abe7867c123652d 4 1 plain 2018-08-27T19:19:06+00:00 Peter Cobb 29b5ca8528741ed24b5845551abe7867c123652dThis page is referenced by:
-
1
2018-08-27T19:19:03+00:00
Saving the Database
1
plain
2018-08-27T19:19:03+00:00
The ideal use case for Libreoffice Base and PostgreSQL on an archaeological project is to have your database and files together on a single, central server. This server may be on the internet somewhere (ie, in the ‘cloud’), or may be a designated computer within your local network at a remote excavation site. Either way, users would connect to this server remotely to get a virtual desktop. This virtual desktop makes it seem to the user like they are sitting at the actual server, even though they are actually connecting to it remotely from their own laptop. In this way, everyone on the project can use the same set of Base user interface files and everyone will be adding, modifying, and using the same dataset stored in PostgreSQL on that server. This enables your team to collaborate and simplifies data management. Sometimes, however, you may want to move your data and files to different computers. The most common use case is that you would want to make a backup copy of your database to store on a different cloud server in order to protect the data.
Saving a database from PostgreSQL is not as straightforward as copying a file from your harddrive. The PostgreSQL software hides the data in its own file structure. In order to get your data and tables out of the database, you will need to make a ‘backup’ copy. You can make a backup using the Pgadmin client interface. By making a backup copy, you extract the data and your data structures to a single file that you can then copy to another computer. In order to use this backup file, you must then do a ‘restore’ on the new computer.
Libreoffice Base files are much simpler to work with, because everything is contained within a single .odb file that you can already copy from one computer to another. Remember that if you move your PostgreSQL database to a new computer and then move your Base file, you will need to reestablish the connection between the two with the JDBC driver on the new computer.
In the following screencast, we will create two types of backup files. You do this by right mouse click on the database itself, then select backup. The first is a .tar file and the second is a .plain file. The .tar file is a good file to use when copying the database to a new computer, but you cannot look inside the file easily. In the screencast, we use this file to ‘restore’ the file to a new database on the same server. The .plain file is useful because you can open that file up to see your data structures and data. This is a text file, and the text you see is in the SQL language, which we will discuss later.
Exercise: Save your Database
Following the steps in the screencast above, make a backup .tar and a backup .plain file from your PostgreSQL database. Also make a backup copy of your Libreoffice Base .odb file. Copy all three files to a single folder. You can consider this new folder as an archive, where you can go to restore your database to what it looked like at a certain time, if you run into a problem. It is not uncommon for people to rename the folder or the individual files with the date the backups were made.