From bdacdf3791ed180a0aaff276eacb518d4dacf990 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 5 Aug 2015 13:22:08 +0300 Subject: Added a simple utility for future-reference. This takes each snapshot on-disk, and uses an intermediary snapshot, to essentially change the ownership of all snapshots from `root` to `byteback`. --- misc/launder-subvolumes | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 misc/launder-subvolumes (limited to 'misc') diff --git a/misc/launder-subvolumes b/misc/launder-subvolumes new file mode 100755 index 0000000..1d43589 --- /dev/null +++ b/misc/launder-subvolumes @@ -0,0 +1,21 @@ +#!/usr/bin/ruby +# +# Convert root-owned snapshots to being owned by the `byteback` user. +# + + +def s(*args) + #print c.join(" ") + "\n" + system(*args) || exit(1) +end + +snapshots = `sudo btrfs subvolume list /store/backups`.split("\n").map { |n| n.split(" ")[8] } + +snapshots.each do |n| + d = "/store/backups/#{n}" + s "sudo -u byteback /sbin/btrfs subvolume snapshot #{d} #{d}-tmp" + s "sudo /sbin/btrfs subvolume delete #{d}" + s "sudo -u byteback /sbin/btrfs subvolume snapshot #{d}-tmp #{d}" + s "sudo -u byteback /sbin/btrfs subvolume delete #{d}-tmp" +end + -- cgit v1.2.1