From bca8250c5a3ed56dae799e4753cd60b211aa390b Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 17 Aug 2011 00:04:15 +0200 Subject: [PATCH] [backup] Add btrfs_snapshot_date.sh Makes a dated snapshot with Btrfs. --- backup/README | 15 +++++++++++++++ backup/btrfs_snapshot_date.sh | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 backup/btrfs_snapshot_date.sh diff --git a/backup/README b/backup/README index f0b2f7e..bb9e3b8 100644 --- a/backup/README +++ b/backup/README @@ -8,6 +8,21 @@ The transfer will be reattempted until it succeed. Edit the script to configure the protocol, host, directories, etc. +# btrfs_snapshot_date.sh # + +This script is a wrapper to btrfs subvolume snapshot, that creates a +snapshot of a subvolume, the snapshot's name being the subvolume name +with the current date and time appended to it. + +It is supposed that the subvolume to snapshot resides in a directory +which needs to be mounted before to make the snapshot (for example if +you defined your default subvolume to your system's root, and mount the +volume 0 on /media/pool). + +Edit the script to configure the directories (and to understand what is +being done). + + # backup_sites_mysql.sh # The script backup_sites_mysql.sh is designed to save websites data files diff --git a/backup/btrfs_snapshot_date.sh b/backup/btrfs_snapshot_date.sh new file mode 100755 index 0000000..83de87d --- /dev/null +++ b/backup/btrfs_snapshot_date.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# btrfs_snapshot_date.sh, Copyright © 2011 Matteo Cypriani +# +# This program is free software. It comes without any warranty, to +# the extent permitted by applicable law. You can redistribute it +# and/or modify it under the terms of the Do What The Fuck You Want +# To Public License, Version 2, as published by Sam Hocevar. See +# http://sam.zoy.org/wtfpl/COPYING for more details. +# +# Makes a snapshot of a Btrfs subvolume with the date appended to its +# name. + +# Mount point of the Btrfs root volume (in which the subvolumes +# reside): +ROOT=/media/pool +# Name of the subvolume to snapshot: +SV="backupsv" + +mount "$ROOT" +SV="$ROOT/$SV" +btrfs subvolume snapshot "$SV" "$SV"_$(date '+%Y-%m-%dT%H:%M:%S')