Skip to content

Commit

Permalink
formats/sh: add [-r] option for deduping read-only snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
SeeSpotRun committed Nov 7, 2016
1 parent d309e89 commit 7806cdc
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/formats/sh.sh
Expand Up @@ -12,6 +12,9 @@ DO_DRY_RUN=
# Set to true on -p
DO_PARANOID_CHECK=

# Set to true on -r
DO_CLONE_READONLY=

##################################
# GENERAL LINT HANDLER FUNCTIONS #
##################################
Expand Down Expand Up @@ -136,7 +139,11 @@ clone() {
# clone $1 from $2's data
echo 'Cloning to: ' "$1"
if [ -z "$DO_DRY_RUN" ]; then
rmlint --btrfs-clone "$2" "$1"
if [ -n "$DO_CLONE_READONLY" ]; then
sudo rmlint --btrfs-clone -r "$2" "$1"
else
rmlint --btrfs-clone "$2" "$1"
fi
fi
}

Expand Down Expand Up @@ -198,14 +205,15 @@ OPTIONS:
-d Do not ask before running.
-x Keep rmlint.sh; do not autodelete it.
-p Recheck that files are still identical before removing duplicates.
-r Allow btrfs-clone to clone to read-only snapshots (requires sudo)
-n Do not perform any modifications, just print what would be done.
EOF
}

DO_REMOVE=
DO_ASK=

while getopts "dhxnp" OPTION
while getopts "dhxnrp" OPTION
do
case $OPTION in
h)
Expand All @@ -221,6 +229,10 @@ do
n)
DO_DRY_RUN=true
;;
r)
DO_CLONE_READONLY=true
echo DO_CLONE_READONLY=true
;;
p)
DO_PARANOID_CHECK=true
esac
Expand Down

0 comments on commit 7806cdc

Please sign in to comment.