Skip to content

Instantly share code, notes, and snippets.

@cstrahan
Forked from tobert/ducker.sh
Created October 28, 2013 03:04
Show Gist options
  • Select an option

  • Save cstrahan/7190874 to your computer and use it in GitHub Desktop.

Select an option

Save cstrahan/7190874 to your computer and use it in GitHub Desktop.
#!/bin/bash
# snapshot the previous volume before updating
# otherwise there will be a CoW for each child, which could get slow quickly
btrfs subvolume snapshot /btrfs/base/precise-amd64-2013-04-01 /btrfs/base/precise-amd64-2013-04-31
# differential copy --inplace avoids the tempfile/mv so large files can remain shared
rsync -avx --inplace --delete server.domain.com::precise-amd64 /btrfs/base/precise-amd64-2013-04-31
# now make a snapshot for an app
btrfs subvolume snapshot /btrfs/base/precise-amd64-2013-04-31 /btrfs/image/ID
# then pull the app's 'overlay', no --delete since it should just be the diff
rsync -avx --inplace server.domain.com::app-ID /btrfs/image/ID
# now create a container for the app to run in
btrfs subvolume snapshot /btrfs/image/ID /btrfs/app/ID-INSTANCE
# check out your new container
chroot /btrfs/app/ID-INSTANCE /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment