X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=bin%2Flive-snapshot;h=d70ef36e62027bae0b91603a40e88bf0e5d3364f;hb=6c6c31fe8348213396d7bd2dcfea72e0299debf9;hp=3d4efad0da20bdb3c9adcb8f26083b7013b9403d;hpb=b3416142f2a676acbfca0738ea386d40bef74313;p=live-boot-grml.git diff --git a/bin/live-snapshot b/bin/live-snapshot index 3d4efad..d70ef36 100755 --- a/bin/live-snapshot +++ b/bin/live-snapshot @@ -59,6 +59,7 @@ TMP_FILELIST="${PROGRAM}.list" # Command line defaults and declarations SNAP_COW="${DEF_SNAP_COW}" SNAP_DEV="" +SNAP_MNT="" SNAP_OUTPUT="" SNAP_RESYNC_STRING="" SNAP_TYPE="cpio" @@ -99,7 +100,7 @@ Help () echo " -o, --output: output image file (default: ${DEST})." echo " -r, --resync-string: internally used to resync previous made snapshots." echo " -f, --refresh: try to sync a running snapshot." - echo " -t, --type: snapshot filesystem type. Options: \"squashfs\", \"ext2\", \"ext3\", \"jffs2\" or \"cpio\".gz archive (default: ${SNAP_TYPE})" + echo " -t, --type: snapshot filesystem type. Options: \"squashfs\", \"ext2\", \"ext3\", \"ext4\", \"jffs2\" or \"cpio\".gz archive (default: ${SNAP_TYPE})" echo echo "Look at live-snapshot(1) man page for more information." @@ -239,9 +240,10 @@ Defaults () then SNAP_COW=$(echo "${SNAP_RESYNC_STRING}" | cut -f1 -d ':') SNAP_DEV=$(echo "${SNAP_RESYNC_STRING}" | cut -f2 -d ':') - DEST="${MOUNTP}/$(echo ${SNAP_RESYNC_STRING} | cut -f3 -d ':')" + SNAP_MNT=$(echo "${SNAP_RESYNC_STRING}" | cut -f3 -d ':') + DEST="${MOUNTP}/${SNAP_MNT}" - case "${DEST}" in + case "${SNAP_MNT}" in *.cpio.gz) SNAP_TYPE="cpio" ;; @@ -254,9 +256,18 @@ Defaults () SNAP_TYPE="jffs2" ;; - ""|*.ext2|*.ext3) + *.ext2|*.ext3) SNAP_TYPE="ext2" ;; + + "") + SNAP_TYPE="whole_partition" + ;; + + *.ext4) + SNAP_TYPE="ext4" + ;; + *) Error "unrecognized resync string" ;; @@ -276,6 +287,10 @@ Defaults () ext3) DEST="${MOUNTP}/live-sn.ext2" ;; + + ext4) + DEST="${MOUNTP}/live-sn.ext4" + ;; esac else DEST="${SNAP_OUTPUT}" @@ -285,7 +300,7 @@ Defaults () Validate_input () { case "${SNAP_TYPE}" in - cpio|squashfs|jffs2|ext2|ext3) + cpio|squashfs|jffs2|ext2|ext3|ext4|whole_partition) ;; *) @@ -404,7 +419,14 @@ Do_snapshot () mksquashfs "${SNAP_COW}" "${DEST}" -ef "${TMP_FILELIST}" ;; - cpio) + cpio|whole_partition) + if [ "${SNAP_TYPE}" = "cpio" ] + then + COPY_CMD="cpio --quiet -o0 -H newc | gzip -9c > ${DEST}" + else + COPY_CMD="cpio --quiet -pumd0 ${DEST}/" + fi + WORKING_DIR=$(Do_filelist "${TMP_FILELIST}") cd "${WORKING_DIR}" if [ -e "${EXCLUDE_LIST}" ] @@ -417,19 +439,17 @@ Do_snapshot () grep -F -v -f "${EXCLUDE_LIST}" | \ tr '\n' '\0' | \ tr '\1' '\n' | \ - cpio --quiet -o0 -H newc | \ - gzip -9c > "${DEST}" || exit 1 + $COPY_CMD || exit 1 else cat "${TMP_FILELIST}" | \ - cpio --quiet -o0 -H newc | \ - gzip -9c > "${DEST}" || exit 1 + $COPY_CMD || exit 1 fi cd "${OLDPWD}" ;; - # ext2|ext3 and jffs2 does not easily support an exclude list; files + # ext2|ext3|ext4 and jffs2 does not easily support an exclude list; files # should be copied to another directory in order to filter content - ext2|ext3) + ext2|ext3|ext4) DU_DIM="$(du -ks ${SNAP_COW} | cut -f1)" REAL_DIM="$(expr ${DU_DIM} + ${DU_DIM} / 20)" # Just 5% more to be sure, need something more sophistcated here... genext2fs --size-in-blocks=${REAL_DIM} --reserved-percentage=0 --root="${SNAP_COW}" "${DEST}" @@ -462,7 +482,7 @@ Warn_user () if [ -z "${SNAP_RESYNC_STRING}" ] then case ${SNAP_TYPE} in - cpio|ext2|ext3) + cpio|ext2|ext3|ext4) echo "Please move ${DEST} (if is not already in it)" > /dev/null 1>&2 echo "in a supported writable partition (e.g ext3, vfat)." > /dev/null 1>&2 ;;