Last active
August 29, 2015 14:07
-
-
Save luelista/f064ddd5551997f00b05 to your computer and use it in GitHub Desktop.
export_rsnapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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