Your YAMS configuration is precious! Let’s make sure it’s properly backed up so you can recover from any mishaps.
YAMS includes a super handy backup command that takes care of everything:
yams backup [destination]
Let’s say you want to back up to your home directory:
yams backup ~/backups/
You’ll see something like this:
Stopping YAMS services...
Backing up YAMS to /home/roger...
This may take a while depending on the size of your installation.
Please wait... ⌛
Backup completed! 🎉
Starting YAMS services...
Backup completed successfully! 🎉
Backup file: /home/roger/yams-backup-2024-12-23-1734966570.tar.gz
The backup includes:
Need to restore your YAMS setup? Here’s the step-by-step guide:
tar -xzvf your-backup.tar.gz -C /your/new/location
cd /your/new/location
Edit the YAMS binary with your favorite text editor (we’ll use nano
here, but use whatever you prefer):
nano yams
Find and update these lines:
#!/bin/bash
set -euo pipefail
# Constants
readonly DC="docker compose -f your/new/location/docker-compose.yaml -f your/new/location/docker-compose.custom.yaml" # Update this!
readonly INSTALL_DIRECTORY="your/new/location" # Update this!
sudo cp yams /usr/local/bin/
yams start
Regular Schedule
# Example: Weekly backups to different locations
yams backup ~/backups/weekly/
yams backup /mnt/external/yams-backup/
Pre-Update Backups
# Before running yams update
yams backup ~/backups/pre-update/
df -h
ls -la /backup/destination
yams stop
tar -tvf your-backup.tar.gz
You can automate backups using cron. Here’s an example:
Open your crontab:
crontab -e
Add a weekly backup job:
# Run backup every Sunday at 2 AM
0 2 * * 0 /usr/local/bin/yams backup /path/to/backups/
Keep your backups manageable with rotation:
#!/bin/bash
# backup-rotate.sh
MAX_BACKUPS=5
BACKUP_DIR="/path/to/backups"
# Create new backup
yams backup $BACKUP_DIR
# Remove old backups
ls -t $BACKUP_DIR/yams-backup-* | tail -n +$((MAX_BACKUPS + 1)) | xargs rm -f
If you run into backup or restore issues:
Remember: The best time to make a backup is BEFORE you need it! 🎯