Skip to content
induslevel.com
Menu
  • Home
Menu

How to Backup ZFS Snapshots to AWS Glacier

Posted on January 20, 2024 by Waqar Azeem

I was looking for offsite backup for my ubuntu server which has ZFS file system. I used Sanoid to take snapshots and Syncoid to replicate the snapshots to a different pool on seperate disk. Now, I want to replicate the snapshot to AWS Glacier.

I found a great tool “zfs-to-glacier” by Anders. Following how-to document is based on the instructions given in github repository.

Prerequisites

You need to have zfs snapshotting mechanism already in place. This tool will only replicate the snapshots to AWS Glacier

Update the Installation

It is always a good approach to install latest updates

sudo apt-get update
sudo apt-get upgrade -y

Package Download

Download the binary from the Github page. I am using the latest binary available at this time.

sudo su -
cd /usr/local/bin/
wget https://github.com/andaag/zfs-to-glacier/releases/download/release-e6c376993da13ec0295999cc332b445338b9f5c2/zfs_to_glacier_amd64
chmod 755 zfs_to_glacier_amd64

Local Configuration

Generate the local configuration. This will create file name “config.yaml” in present working directory

cd /root/
zfs_to_glacier_amd64 generateconfig

Edit Local Configuration

Edit the config.yaml and update the pool from where you want to replicate the snapshots. In my case, it is raidpool. Here is how the file looks like:

- pool_regex: "raidpool/.*"
  incremental:
    snapshot_regex: "daily"
    storage_class: "StandardInfrequentAccess"
    expire_in_days: 40
  full:
    snapshot_regex: "monthly"
    storage_class: "DeepArchive" #minimum storage period as of this writing is 180 days for deeparchive.
    expire_in_days: 200
  bucket: "zfs-raidpool" #You can backup multiple pools to one bucket.

Cloudformation Configuration

Execute following command to create equivalent configuration file for cloudformation.

zfs_to_glacier_amd64 generatecloudformation

You will get file with name cloudformation_zfsbackup.yaml. The Cloudformation file will looks like this:

AWSTemplateFormatVersion: '2010-09-09'
Description: ZFS backup config
Resources:
  ZfsRaidpool:
    Type: 'AWS::S3::Bucket'
    Properties:
      BucketName: 'zfs-raidpool'
      AccessControl: Private
      PublicAccessBlockConfiguration:
        BlockPublicAcls: true
        BlockPublicPolicy: true
        IgnorePublicAcls: true
        RestrictPublicBuckets: true
      LifecycleConfiguration:
        Rules:
          - Id: DeleteFull
            Prefix: 'full/'
            Status: Enabled
            ExpirationInDays: 200
          - Id: DeleteIncremental
            Prefix: 'incremental/'
            Status: Enabled
            ExpirationInDays: 40
          - Id: AbortIncompleteMultipartUpload
            Status: Enabled
            AbortIncompleteMultipartUpload:
              DaysAfterInitiation: 7
  CustomUser:
    Type: 'AWS::IAM::User'
    Properties:
      UserName: 'BackupAccount'
      Policies:
        - PolicyName: 'CustomRole'
          PolicyDocument:
            Statement:
              - Effect: Allow
                Action:
                  - s3:PutObject
                  - s3:GetObjectTagging
                  - s3:PutObjectTagging
                  - s3:ListBucket
                  - s3:AbortMultipartUpload
                  - s3:ListMultipartUploadParts
                Resource:
                  - !Join ['', ['arn:aws:s3:::', 'zfs-raidpool' ]]
                  - !Join ['', ['arn:aws:s3:::', 'zfs-raidpool/*' ]]

Cloud Formation

Login to AWS Console and Upload the yaml file to CloudFormation to create new stack. Once process is complete, you will get to see a new bucket and User created


Access Key

Go to IAM user page and download the Access Key for this newly created user. In my case, it is BackupAccount


AWSCLI Installation

Install AWSCLI tool

apt-get install awscli -y

Configure Access Key

Configure it with the Access Key we just downloaded.

aws configure
AWS Access Key ID [None]: XXXXXXXXXXXXXXXXXXX
AWS Secret Access Key [None]: yyyyyyyyyyyyyyyyyyyyyyyyyy
Default region name [None]: us-east-1
Default output format [None]: 

Dry Run

Use the following script to dry run and size estimate for the backup

zfs_to_glacier_amd64 sync -v -n
zfs_to_glacier_amd64 estimate_size

Sync Script

You can use the following script via cron to start the replication. There is better script mentioned in the repository

#!/bin/bash
nice zfs_to_glacier_amd64 sync -v &> /var/log/awsbackup.log

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • More
  • Click to print (Opens in new window) Print
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to email a link to a friend (Opens in new window) Email

Related Articles

Share your thoughtsCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Easiest Way to Setup WordPress and OpenConnect VPN Server using Ansible
  • How to use port 443 for SSH and OpenConnect VPN on Linux using HAProxy
  • How to Backup ZFS Snapshots to AWS Glacier
  • How to Install and Setup OpenConnect VPN Server on CentOS 7
  • How to Compile Kitty SSH Client from Source Code

Recent Comments

  1. Waqar Azeem on How to Install and Setup Kubernetes Cluster with Flannel CNI in CentOS 7
  2. Owais Khaleeq on How to Install and Setup Kubernetes Cluster with Flannel CNI in CentOS 7
  3. Muhammad Rizwan Latif on How To Setup 3-Node DynaTrace Managed Cluster on Centos/Redhat 7
  4. Waqar Azeem on How To Setup 3-Node DynaTrace Managed Cluster on Centos/Redhat 7
  5. Tahir on How to Install Simple DHCP Server in Centos 7

Archives

  • August 2024
  • February 2024
  • January 2024
  • July 2023
  • October 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021

Categories

  • Uncategorized
© 2025 INDUS LEVEL | Powered by Minimalist Blog WordPress Theme
 

Loading Comments...