summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-08-05 13:22:08 +0300
committerSteve Kemp <steve@steve.org.uk>2015-08-05 13:22:08 +0300
commitbdacdf3791ed180a0aaff276eacb518d4dacf990 (patch)
tree7d1f3fd6f7500215fe898be45ba37ba42d2a1842
parent3ddaa84539cb14f653eeeccba67cab39392896f1 (diff)
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`.
-rwxr-xr-xmisc/launder-subvolumes21
1 files changed, 21 insertions, 0 deletions
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
+