Restoring Backups

This section explains how to perform a restore from a previously performed back up.

See the Backups section to create a consistent backup of your system.

Note

These instructions are intended to “restore” against an existing Posit Connect installation. If you have lost your entire Posit Connect host, you will need to install Posit Connect and its dependencies before following these steps.

Warning

Do not perform a restore operation while Posit Connect is running.

The Posit Connect service is stopped during a restore, preventing modifications to the Connect database and its variable data while their state is being reset.

Prerequisites

  1. Either root or sudo access on the target Connect servers.

    Managing the Connect service, its configuration, and its variable data requires elevated privileges.

  2. Determine file-system restore procedure.

    The steps to restore your files-system depend on your infrastructure. Some systems offer snapshots, which record the state of the file-system at a particular point in time.

    The restore MUST preserve file ownership, permissions, and special files like symbolic links.

    If backed up with rsync, cp, or tar, you will use those same commands to restore.

    # Example restore commands
    sudo rsync -a /mnt/backups/rstudio-connect/ /var/lib/rstudio-connect
    sudo cp -a /mnt/backups/rstudio-connect/ /var/lib/rstudio-connect
    sudo tar xvpzf /mnt/backups/rstudio-conect.tar.gz -C /var/lib/rstudio-connect
  3. Determine database restore procedure.

    When using SQLite, its data files should be included within your file-system backups and do not require an additional restore step. This may not hold if you have customized SQLite.Dir or Database.Dir.

    The steps to restore PostgreSQL depend on your infrastructure and how PostgreSQL is running. Some services, such as Amazon RDS, can restore database snapshots on your behalf.

    If you are running your own PostgreSQL server, you may need to use psql or pg_restore, to restore into a newly created database with a command such as:

    # Run on the PostgreSQL server as the database superuser,
    # which is often the "postgres" account.
    sudo -u postgres psql -d connect < connect-backup.sql

Workflow

Step 1: Stop Connect

Stop the Connect service on each server in the target environment.

sudo systemctl stop rstudio-connect

Step 2: Restore from backup

Run the appropriate steps to restore your file-system and database.

This may mean recovering from a “snapshot” or it could mean running a series of commands to transfer data from your archives to the correct locations.

Your restore MUST preserve file ownership and permissions, as these attributes are necessary for content execution.

Multi-node environments need to restore the file-system and database once, as those are shared resources. Configuration files, such as /etc/rstudio-connect/rstudio-connect.gcfg need to be copied onto each server.

Note

Posit Connect file-system and database backups are not complete system backups, and there may be other items you need to transfer or recreate, depending on your Posit Connect configuration and content, such as user accounts or the set of installed system packages.

If you are restoring from a backup as part of a server migration, see the Server Migration for more detailed instructions.

Step 3: Start Connect

Start the Connect service on each server in the target environment.

sudo systemctl start rstudio-connect