Introduction
This guide provides instructions on how to schedule Terraform Enterprise snapshots using the replicatedctl command-line interface (CLI).
Expected Outcome
You will successfully configure a snapshot schedule for your Terraform Enterprise instance via the CLI.
Prerequisites
- A Terraform Enterprise instance running in the Proof of Concept operational mode.
Use Case
This procedure is useful when you have limited access to the Replicated admin console and need to set up or change the snapshot schedule.
Procedure
Follow these steps to configure the snapshot schedule.
- Connect to your Terraform Enterprise instance via SSH.
-
Check the current Replicated snapshot settings. This command exports all parameters and filters for snapshot-related keys.
$ replicatedctl params export | grep -i snapshot
The output displays your current snapshot configuration. Pay special attention to the
SnapshotsSchedule,DisableScheduledSnapshots, andSnapshotsMaxBackupsvalues."SnapshotsBindAddress": "0.0.0.0:9878", "SnapshotsAdvertiseAddress": "192.168.78.152:9878", "SnapshotsStore": "local", "SnapshotsPath": "/var/lib/replicated/snapshots", "SnapshotsS3Bucket": "", "SnapshotsS3Folder": "", "SnapshotsAWSRegion": "", "SnapshotsAWSKeyID": "", "SnapshotsAWSSecretKey": "", "SnapshotsAWSServerSideEncryption": "", "SnapshotsAWSSSEKMSKeyID": "", "SnapshotsAWSS3CompatibleEndpoint": "", "SnapshotsSFTPHost": "", "SnapshotsSFTPUsername": "", "SnapshotsSFTPPrivateKeyPEM": "", "SnapshotsSFTPPrivateKeyPEMFilename": "", "SnapshotsSchedule": "5 21 * * Thu", "DisableScheduledSnapshots": false, "SnapshotsMaxBackups": 3, "SnapshotsTimeout": 0, "RetracedSnapshotMaxFilesize": "128m"
-
Verify the date and time inside the Replicated container, as it may differ from the host system's time. All schedules are based on the container's time.
$ docker exec replicated date
Example output:
Fri Sep 30 14:20:45 UTC 2022
- Set the new snapshot schedule using one of the following formats.
-
Hourly
## Set the schedule to run hourly. $ replicatedctl params set SnapshotsSchedule --value '@hourly'
-
Daily
## Set the schedule to run daily at 8:30 PM. $ replicatedctl params set SnapshotsSchedule --value '30 20 * * *'
-
Weekly
## Set the schedule to run weekly on Saturday at 9:00 AM. $ replicatedctl params set SnapshotsSchedule --value '0 9 * * Sat'
-
Additional Information
HashiCorp does not recommend using snapshots as a primary backup strategy. Instead, use the Backup and Restore API and refer to the Terraform Enterprise Backup - Recommended Patterns for more in-depth, cloud-specific recommendations.