SQLite

SQLite is the default database provider.

RStudio Connect will use SQLite database if the Database.Provider setting has a value of sqlite or if Provider is not present in the configuration file.

; /etc/rstudio-connect/rstudio-connect.gcfg
[Database]
Provider = sqlite

You can also specify the directory to store the SQLite file on your file system. This can be done by specifying SQLite.Dir in the configuration file.

; /etc/rstudio-connect/rstudio-connect.gcfg
[SQLite]
Dir = /mnt/connect/sqlite

If this field is not specified, it will default to {Server.DataDir}/db. This location must exist on local storage.

If the location for Server.DataDir is not local storage but a networked location over NFS, configure the SQLite.Dir setting so it still resides on some local volume.

SQLite Backups

RStudio Connect can be configured to periodically back up its database while running.

; /etc/rstudio-connect/rstudio-connect.gcfg
[SQLite]
Backup = true
BackupFrequency = 24h
BackupRetentionLimit = 7

The above config will execute an online backup every 24 hours. RStudio Connect will retain up to 7 of those backups. If an eigth backup is created, the oldest of the previous backups will be deleted. This provides a grace period for an administrator implementing a data retention policy, such as a practice of copying backups to tape periodically.

Backups are stored in the same directory as the main database file: /var/lib/rstudio-connect/db by default. Backups are lexically sortable, because they are timestamped with the UNIX epoch time padded to 11 digits. For example, if the server's database file is /var/lib/rstudio-connect/db/connect.db, a backup of that database could be /var/lib/rstudio-connect/db/connect.db.01508526538.

The same process is applied to the instrumentation database file. It will be backed up based on the same settings as for the main database file.

Automatic SQLite backups are not a complete backup solution for RStudio Connect. You should also make regular backups of the Server.DataDir directory. This is especially important because the Server.DataDir directory is expected to be kept in sync with the database.

Restoring a SQLite backup is straightforward:

  • Ensure that the backup is valid with the command sqlite3 <backup file name> "PRAGMA integrity_check;"

  • Stop the RStudio Connect service

  • Copy the current database file as well as its .wal file, if any. (If you wish to analyze them or send a copy to RStudio Support)

  • Replace the current database file with the backup

  • If they exist, delete any .wal and .shm files associated with the previous database. Failure to do this could lead to further downtime and possible data corruption.

  • Start the RStudio Connect service

Note also that RStudio Connect has no way of restoring applications deployed or changes made since the last backup. Restoring the backup file will cause these changes to be lost permanently.