3.8 KiB
title, date, draft, weight, summary
title | date | draft | weight | summary |
---|---|---|---|---|
Backups | 2023-01-17T19:38:39-03:00 | false | 80 | Everything you need to know about backing up and restoring your YAMS setup |
Keeping Your YAMS Safe 💾
Your YAMS configuration is precious! Let's make sure it's properly backed up so you can recover from any mishaps.
Creating Backups 📦
YAMS includes a super handy backup command that takes care of everything:
yams backup [destination]
Quick Backup Example
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
What Gets Backed Up? 🤔
The backup includes:
- All your container configurations
- Your YAMS settings
- Your service preferences
- Custom container configurations
- Important environment variables
Pro Backup Tips 💡
- Regular Backups: Schedule them weekly or monthly
- Multiple Locations: Keep copies in different places
- Before Updates: Always backup before updating YAMS
- Version Control: Keep a few recent backups around
- Test Restores: Occasionally verify your backups work
Restoring from Backup 🔄
Need to restore your YAMS setup? Here's the step-by-step guide:
Step 1: Extract the Backup
tar -xzvf your-backup.tar.gz -C /your/new/location
cd /your/new/location
Step 2: Update YAMS Configuration
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!
Step 3: Install YAMS Binary
sudo cp yams /usr/local/bin/
Step 4: Start YAMS
yams start
Best Practices 📚
-
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/
Troubleshooting 🔧
Backup Failed?
- Check disk space:
df -h
- Verify write permissions:
ls -la /backup/destination
- Try stopping services manually:
yams stop
Restore Issues?
- Verify backup integrity:
tar -tvf your-backup.tar.gz
- Check file permissions
- Ensure all paths are correct in the YAMS binary
Advanced Topics 🎓
Automated Backups
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/
Backup Rotation
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
Need Help? 🆘
If you run into backup or restore issues:
- Check our Common Issues page
- Visit the YAMS Forum
- Join our Discord or Matrix chat
Remember: The best time to make a backup is BEFORE you need it! 🎯