The Dataverse backup script is a Python-based utility (tested with v. 2.7.10) designed to perform incremental backups of Dataverse datafiles. It relies on a secondary PostgreSQL database to track backup status and uses various drivers for storage and transport.
Prerequisites
The following Python modules are required:
psycopg2: PostgreSQL driver for database access.boto3: AWS SDK for S3 storage access.paramiko: SSH client for SFTP transfers.swiftclient: For OpenStack Swift storage (support is incomplete/experimental).
Core Components
1. Database Requirements
- Access: Uses
psycopg2 to query the main Dataverse database for changed files and to manage its own tracking database. - Tracking Database: A separate database used to maintain the
datafilestatus table. - Constraint: This tracking database must reside on the same server as the main Dataverse database and be owned by the same PostgreSQL user.
- Setup: Refer to
README_HOWTO.txt for instructions on setting up this database before running the script.
2. Storage and Backup Logic
- Storage Access (Reading): Handled via
storage_filesystem.py (local) and storage_s3.py (S3). To add new storage types (e.g., Swift), implement an open_storage_object... method that returns a byte stream. - Backup Access (Writing): Handled via
backup_ssh.py (default) and backup_swift.py (experimental). New backup methods must:- Copy the byte stream to the target storage.
- Verify the copy against the Dataverse checksum (MD5 or SHA1).
3. Backup Status Tracking
The script uses the datafilestatus table in the backup database to manage incremental backups and error states:
OK: File successfully backed up.FAIL_READ: Failed to read the file from Dataverse storage.FAIL_WRITE: Failed to copy or verify the backup copy.- Incremental Logic: The script uses the Datafile
createdate timestamp to identify files created after the latest timestamp recorded in the backup database.
4. Notifications
The script uses the Unix mail command to send status reports. This requires the system to have the mail command installed and configured for command-line email sending.
If you need to use a remote SMTP server instead, you can modify email_notification.py to use smtplib and email.mime.text as shown in the implementation notes.