Skip to content

Migration and OS Upgrades

Moving Posit products to new servers (most often RHEL 8 to RHEL 9 or 10) is the biggest routine project a Posit admin runs. Posit publishes a phased procedure: Upgrade Linux OS and Posit Team.1 This page summarizes it and adds the field notes that the official guide leaves to you.

Do not upgrade the OS in place

Posit recommends building new servers rather than running an in place OS upgrade (for example leapp).2 New servers let you test without touching production and keep the old environment available for comparison and rollback.

The phased approach

flowchart LR
    subgraph P1["Phase 1: build and test staging"]
        PM1("Package Manager") --> WB1("Workbench")
        PM1 --> CN1("Connect")
        WB1 --> AT("Acceptance tests")
        CN1 --> AT
    end
    subgraph P2["Phase 2: migrate data"]
        Stop("Stop production,<br/>snapshot data + DB") --> Copy("rsync data dirs,<br/>restore databases")
        Copy --> Rebuild("Clear and rebuild<br/>runtime caches")
    end
    subgraph Roll["Rollout"]
        DNS("DNS cutover") --> Decom("Decommission old")
    end
    P1 --> P2 --> Roll
    style PM1 fill:#e8f5ec,stroke:#3f8f5a,stroke-width:2px,color:#1a1a1a
    style WB1 fill:#e8f1f8,stroke:#447099,stroke-width:2px,color:#1a1a1a
    style CN1 fill:#fdf1e3,stroke:#c9822b,stroke-width:2px,color:#1a1a1a

Phase 1 builds a complete staging environment (same architecture as production: node count, PostgreSQL, shared storage) with no content, configured from production's config files. Production stays up.

Phase 2 is the outage. Production is stopped so the data directory and database are consistent, then copied into staging.

Rollout is a DNS (or load balancer) change, then decommissioning.

Before you start

Item Old server New server Notes
IP address record record DNS change needed if different
FQDN (hostname -f) record must be set A bare short hostname breaks certificate and launcher checks12
DNS servers and search domains record match /etc/resolv.conf
Ports in use ss -tlnp open in firewall / NSG See Ports
TLS certificate and key path, owner, mode copy Check SANs cover the service URL
SELinux getenforce decide New RHEL images are often Enforcing when the old host was Disabled
firewalld systemctl is-active firewalld decide
Shared storage mounts findmnt, /etc/fstab add to fstab Mount before installing
PostgreSQL connectivity test test Managed DBs need firewall rules per source IP
Service account UIDs/GIDs id rstudio-connect etc. match Required for NFS and HA
R, Python, Quarto versions inventory install Use posit-host
System libraries dnf list installed install Needed for content and source builds
Group definitions posit-groups --export posit-groups --plan See Scripts
User crontabs /var/spool/cron decide Usually move to Connect schedules

The posit-host, posit-workbench, posit-connect, and posit-pm scripts capture most of this table. Run them on both servers and diff the output.

Phase 1 field notes

Set the FQDN

sudo hostnamectl set-hostname wb-prd-02.example.com
hostname -f

Mount shared storage first

If the data directory lives on NFS or Azure Files, the mount must exist before the product starts. Otherwise, the product creates a fresh, empty data directory on local disk.

findmnt /shared
grep shared /etc/fstab

Example NFS entry (Connect needs lookupcache=pos when shared between nodes):13

nfs.example.com:/posit-connect  /shared  nfs  defaults,_netdev,lookupcache=pos  0 0
sudo mount /shared

Create the data directory with the same owner and mode as the old server:

sudo mkdir -p /shared/connect/var/lib/rstudio-connect
sudo chmod 700 /shared/connect/var/lib/rstudio-connect

Certificates

Copy the certificate and key, then put them where the service account can read them:

sudo scp con-prd-01:/etc/rstudio-connect/connect.example.com.crt /tmp/
Product Recommended location Key owner and mode
Workbench /etc/rstudio/ rstudio-server, 0600
Connect /etc/rstudio-connect/ rstudio-connect, 0600
Package Manager /etc/rstudio-pm/ rstudio-pm, 0600

Then verify the certificate and key match: Certificates. Posit's upgrade guide has you place the certificate and key the same way, with the key mode set to 600.3

Trust your internal CA

If your organization uses an internal CA, add its root to the OS trust store on every new server. R, Python, Git, and the products can then verify internal HTTPS endpoints:

sudo cp internal-root-ca.crt /etc/pki/ca-trust/source/anchors/
sudo update-ca-trust

SELinux

Posit's upgrade guide disables SELinux on staging servers to keep the migration simple.3 If your security baseline requires enforcing mode:

  • Workbench ships an SELinux policy module. Install it before enabling enforcing mode, and build a supplementary module for nonstandard paths such as a shared team directory.7
  • The Connect and Package Manager docs describe no policy module, and Connect's requirements say to keep SELinux permissive during installation; test under enforcing mode yourself and resolve denials as they appear

Find denials:

sudo ausearch -m avc -ts recent

Allow a service on a nonstandard port, for example Connect's default HTTP port:

sudo semanage port -a -t http_port_t -p tcp 3939

Do not leave SELinux in an unknown state. Record the decision in your configuration specification.

Package repository URLs

Old configs often hard code the old distribution in Package Manager URLs (__linux__/centos8/). On a RHEL 9 host:

  • In Connect, R.PositPackageManagerURLRewriting = auto (default) or force-binary rewrites incompatible binary URLs automatically, including URLs recorded in already published content910
  • In Workbench, update repos.conf and every Rprofile.site yourself11
sudo grep -rn '__linux__' /etc/rstudio /etc/rstudio-connect /opt/R/*/lib/R/etc/Rprofile.site
sudo sed -i 's|/__linux__/centos8/|/__linux__/rhel9/|g' /etc/rstudio/repos.conf

Acceptance tests

Posit's checklist for staging:4

  1. Start RStudio Pro, JupyterLab, Jupyter Notebook, and VS Code sessions from Workbench
  2. Install an R package in an RStudio Pro session and confirm it installed using binaries from Package Manager
  3. Confirm Shiny content renders in Workbench (checks websockets)
  4. Install a Python package in a VS Code or Jupyter session and confirm it used Package Manager binaries
  5. Confirm a Streamlit or Dash app renders in a VS Code session (checks web proxying)
  6. Publish R content to Connect and confirm Connect used R binaries from Package Manager
  7. Publish Python content from the Workbench terminal with rsconnect-python and confirm Connect used Package Manager for Python packages

Phase 2: moving data

Stop the old service, back up, copy, restore. Ownership and modes must be preserved, so run rsync -a as root.5

sudo systemctl stop rstudio-connect
sudo rsync -aHAX --numeric-ids --info=progress2 con-prd-01:/var/lib/rstudio-connect/ /var/lib/rstudio-connect/

--numeric-ids keeps UIDs as numbers, which is what you want when the service accounts have matching UIDs on both hosts.

For PostgreSQL, follow your organization's backup protocol, typically pg_dump from the old database and pg_restore into the new one.5 If you are not upgrading PostgreSQL, you can point the new server at the same database instead. Never run the old and new servers against it at the same time.

Package Manager

Package Manager data includes things you cannot recreate by reconfiguring: Git and local packages, curated sources, blocklist rules, and usage history. It also holds the hashes that identify frozen repository snapshots, which users and deployed content depend on for reproducibility. Migrate it unless users have agreed to start fresh.5

Shrink the copy first:

sudo rspm evict --type=clear

This limits the number of files rsync has to migrate.5 Then stop, back up, and copy DataDir (default /var/lib/rstudio-pm) with rsync -a, and restore the database.

Connect

After a Linux distribution change, content runtime caches (installed R and Python packages per content) are incompatible with the new OS. Clear them; content rebuilds on first run. Preemptively rebuild your most important content, such as interactive applications and APIs, so users do not wait.85

Common rebuild failures:5

  • Content built under a now-deprecated version of R or Python
  • A package no longer available, or not available for the new OS
  • A package installed from a source that is no longer available (an old GitHub ref, a retired internal repo)

These need the content owner. Keep a list and work through it.

Workbench

Stop the service, then suspend any sessions still tracked, in that order:5

sudo rstudio-server stop
sudo rstudio-server suspend-all

Home directories usually live on shared storage and simply get mounted on the new host. After an OS change, user R libraries (~/R/x86_64-pc-linux-gnu-library/), Python virtual environments, and renv caches contain binaries built for the old OS. Users must rebuild them.5 Tell them before cutover, and give them the commands:

renv::restore(rebuild = TRUE)

Rollout

Posit's guide leaves the cutover mechanics to your organization's own procedures for DNS, user notification, and decommissioning.6 A workable pattern: lower the DNS TTL a day ahead, then switch the record (or load balancer backend) to the new IP:

dig +short connect.example.com
curl -I https://connect.example.com

Keep the old servers stopped but intact until users have confirmed the new environment works. Decommission on a set date.

Case study: Connect RHEL 8 to RHEL 9

A condensed runbook from a real migration, with placeholders:

Step Command or action Check
1. Set FQDN hostnamectl set-hostname con-prd-02.example.com hostname -f
2. Copy cert and key scp from old host, chmod 600 key Modulus match
3. Fix repository URLs sed -i 's|/__linux__/centos8/|/__linux__/rhel9/|g' (or rely on URL rewriting) grep URL rstudio-connect.gcfg
4. SELinux Policy or documented decision getenforce, no AVC denials
5. Start Connect systemctl enable --now rstudio-connect ss -tlnp | grep -E ':(80|443)\b'
6. Migrate data Stop old, rsync -a, restore DB Content list matches
7. Clear runtime caches Per Connect admin guide Key content rebuilds
8. DNS cutover Change A record curl -I returns 200 or 302