Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Backing Up a LXD Server

While there are multiple methods to backing up a LXD server, one way involves creating a second LXD server to work as a live spare that we can failover to should the need arise. This server will contain recent copies of our containers and should be set up to automatically receive these container copies. In this hands-on lab, we'll be doing just that. We'll create a secondary backup server, then write a short Bash script to copy over our backups. This script will then get added to our crontab to run automatically.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Beginner
Last updated
Apr 06, 2025
Duration
30m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Configure the Remote

    Log in to the "Backup Remote" server. LXD has already been installed, and only needs to be configured:

    lxd init
    

    Use the default settings until asked if LXD should be available over the network, then type yes. Bind to all addresses and the default port, then set the password to pinehead:

    Would you like LXD to be available over the network? (yes/no) [default=no]: yes
    Address to bind LXD to (not including port) [default=all]:
    Port to bind LXD to [default=8443]:
    Trust password for new clients: pinehead
    Again: pinehead
    

    On the LXD server, add the Backup server as a remote:

    lxc remote add backups 10.0.1.110
    
  2. Challenge

    Write a Backup Script

    To create a backup, we want to work in two steps: Taking the snapshot and copying over the snapshot over to the backup remote. We also need to remove any existing backup snapshots and containers:

    #! /bin/bash
    
    containers="web1 db1"
    
    for c in $containers
    do
            lxc delete $c/backup &> /dev/null
            lxc snapshot $c backup
            lxc delete backup:$c &> /dev/null
            lxc copy local:${c}/backup backups:$c
    done
    

    When finished, ensure the script is executable:

    chmod +x backups.sh
    
  3. Challenge

    Add the Script to the Crontab

    Add the script to your crontab:

    crontab -e
    
    0 0 * * * /home/cloud_user/backups.sh
    
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight