Skip to content

Instantly share code, notes, and snippets.

@luelista
Last active August 29, 2015 14:07
Show Gist options
  • Save luelista/f064ddd5551997f00b05 to your computer and use it in GitHub Desktop.
Save luelista/f064ddd5551997f00b05 to your computer and use it in GitHub Desktop.
export_rsnapshot
#!/bin/bash
RSNAPDIR=/.private/.snapshots
EXPDIR=$1
if [ -z "$EXPDIR" ]; then
echo Please give folder
exit 12
fi
if [ "${EXPDIR:0:1}" = "/" ]; then
EXPDIR=${EXPDIR:1}
fi
if [ -d "$RSNAPDIR/daily.0/$EXPDIR" ]; then
echo exporting $EXPDIR
else
echo Error, folder does not exist
exit 11
fi
ARCHIVE=export.tar
# tar --create --gzip -f $ARCHIVE
rm $ARCHIVE
for ts in $RSNAPDIR/*.* ; do
if [ -d "$ts" ]; then
TS=$(basename "$ts")
echo Exporting from $TS ...
tar --append --transform "s|^${ts:1}/$EXPDIR|$TS|" -f $ARCHIVE $ts/$EXPDIR
fi
done
echo Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment