Automating Backups for Your AI Projects on Linux
Stepâbyâstep guide (2025)
Why Backup Matters
If youâre a data scientist, hobbyist, or student whoâs just started tinkering with machine learning, the biggest headache isnât the model architecture. Itâs the fact that your workstation is a single point of failure. One power outage, one accidental ârm -rf /â, and all your notebooks, datasets, and trained weights are gone.
I built my own AIâready Linux workstation for under $800 last year: an AMD RyzenâŊ5 5600X, an NVIDIA RTXâŊ3060, a fast NVMe SSD, and a secondary SATA drive for backups. After setting up CUDA, LM Studio, and Golem for distributed training, I hit âRunâ and realized the real test began: How do I keep all that data safe?
This guide walks you through automating backups on Linuxâhardware choices, OS setup, GPU drivers, and a fullyâautomated snapshot pipelineâso you can focus on building models instead of fearing data loss.
1. Pick Reliable Hardware (and Save)
| Component | Why It Matters | Affiliate | â |-----------|----------------|-----------| â | Motherboard with SATA & NVMe | Allows adding a secondary drive later without buying another board. | â |
| DualâBIOS / BIOS recovery | Prevents boot issues if you accidentally flash the wrong firmware. | â | â | 80+ Bronze PSU | Reduces risk of sudden power loss that could corrupt drives. | â | â | NVMe SSD (500âŊGB+) for OS & training data | Faster I/O speeds mean less time waiting during backup. | â |
| Secondary SATA SSD or HDD (1â2âŊTB) for backups | Keeps your primary drive free from wear and acts as a quick restore point. | â |
Tip: Even on a tight budget, invest in at least one redundant drive. Itâs the cheapest way to avoid catastrophic data loss.
2. Install Ubuntu (or Debianâbased distro) with DualâBoot for Safety
-
Create bootable USB â Use Rufus or
dd. -
Partitioning â Allocate ~300âŊGB for
/home, leaving the rest for OS and swap. - Install Ubuntu 24.04 LTS (or your choice).
- Disable Secure Boot if you plan to use custom kernels or drivers that arenât signed.
Why dualâboot? A Windows or another Linux install gives you a fallback if the primary OS becomes corrupted.
3. Install NVIDIA Drivers & CUDA Toolkit
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo ubuntu-drivers autoinstall # installs the recommended driver (e.g., 535)
Verify with nvidia-smi.
If youâll use Docker containers that need GPU access, install the NVIDIA Container Toolkit:
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt update && sudo apt install -y nvidia-docker2
sudo systemctl restart docker
Pro tip: Keep the driver version aligned with your CUDA toolkit to avoid runtime errors.
4. Set Up LM Studio (or JupyterLab) for Development
python3 -m venv ~/ai-env
source ~/ai-env/bin/activate
pip install lmstudio==0.x # replace with latest
Configure GPU usage in your scripts:
device = torch.device("cuda").
Why LM Studio? It bundles a lightweight IDE, GPU monitoring, and quick access to popular modelsâperfect for rapid prototyping.
5. Deploy Golem (or Similar Distributed Training Framework)
pip install golem
Configure your node to point to the /home partition where data lives.
Set up a task queue so each job writes checkpoints back to the backup drive, and monitor with golem status.
Why Golem? It turns idle GPUs into compute resources while keeping your local data isolated on the main SSD.
6. Automate Backups: The Core of the Guide
A. Pick a Backup Tool â BorgBackup
| Tool | Pros | Cons | â |------|------|------| â | rsync + cron | Simple, no extra deps. | Manual incremental config. | â | BorgBackup (borg) | Deduplication, compression, encryption. | Slight learning curve. | â | Restic | Fast, easy setup, cloud backends. | No native deduplication. |
Weâll use BorgBackup for its balance of speed and space efficiency.
B. Install Borg
sudo apt install borgbackup
C. Create a Backup Repository
Mount your secondary SATA SSD at /mnt/backup and run:
mkdir -p /mnt/backup/borg_repo
borg init --encryption=repokey /mnt/backup/borg_repo
Youâll be prompted for a passphraseâkeep it safe but accessible.
D. Backup Script
Create /usr/local/bin/ai_backup.sh:
#!/bin/bash
# AI Backup Script â Borg + cron
export BORG_REPO=/mnt/backup/borg_repo
export BORG_PASSPHRASE="YOUR_PASS_PHRASE"
SOURCE="/home"
EXCLUDE=("--exclude=.cache" "--exclude=*.tmp" "--exclude=~/datasets/tmp")
borg create \
--verbose \
--filter AME \
--list \
--stats \
--compression lz4 \
"${BORG_REPO}::$(date +%Y-%m-%d-%H%M%S)" \
$SOURCE ${EXCLUDE[@]}
# Prune older backups (keep last 7 daily, 4 weekly)
borg prune \
--list \
-v \
--keep-daily=7 \
--keep-weekly=4 \
$BORG_REPO
Make it executable:
sudo chmod +x /usr/local/bin/ai_backup.sh
E. Schedule with cron
Edit your crontab:
# AI backup â every day at 2âŊAM
0 2 * * * /usr/local/bin/ai_backup.sh >> ~/ai-backup.log 2>&1
Now backups run unattended. Check ~/ai-backup.log for any errors.
F. Test Restoration
borg extract --verbose \
$BORG_REPO::2025-12-01-020000 \
/home/user/test_file.txt
Confirm the file matches the original.
7. Optional: OffâSite Cloud Backup (Backblaze B2)
- Create a bucket on Backblaze B2.
- Install
b2CLI and authenticate. - Add to your script after the local backup:
# Upload repo snapshot to B2
b2 upload-file $BORG_REPO /path/to/repo b2://my-ai-backups/$(date +%Y-%m)
This adds an extra layer of protection against hardware failure.
Recap & Call to Action
You now have a complete, automated backup pipeline that protects your AI projects on Linuxâfrom the initial $800 build to nightly snapshots that keep data safe.
Whatâs your setup? Drop a comment below with your hardware choices, any tweaks you made, or questions you have. And if youâre looking for a GPU upgrade or faster storage, check out our affiliate links:
- â great performance for under $300
- â fast, reliable storage for your OS and datasets
Happy trainingâand stay backed up!
Top comments (2)
Solid infrastructure writeup! While backups are essential, there's another equally important dimension to protecting AI projects: reproducibility and determinism.
Imagine this scenario: You restore a backup of your training pipeline, but when you re-run it with the same data and hyperparameters, you get different results. The backup is useless if you can't reproduce what you backed up.
This is where explicit contracts matter for AI systems:
When you combine:
You get truly recoverable AI projects. A backup without reproducibility is just a fancy archive.
Great infrastructure workâwould be interesting to see this integrated with contract-layer tooling for full end-to-end recovery!
Well said, and i completely agree.