SNAP_RESYNC_STRING=""
SNAP_TYPE="cpio"
SNAP_LIST="/etc/live-snapshot.list"
+EXCLUDE_LIST="/etc/live-snapshot.exclude_list"
Error ()
{
# Removing whiteheads of unionfs
cd "${SNAP_COW}"
find . -name '*.wh.*' >> "${TMP_FILELIST}"
+
+ if [ -e "${EXCLUDE_LIST}" ]
+ then
+ # Add explicitly excluded files
+ cat "${EXCLUDE_LIST}" | grep -v '^#.*$' | grep -v '^ *$' >> "${TMP_FILELIST}"
+ fi
+
cd "${OLDPWD}"
mksquashfs "${SNAP_COW}" "${DEST}" -ef "${TMP_FILELIST}"
;;
cpio)
WORKING_DIR=$(Do_filelist "${TMP_FILELIST}")
cd "${WORKING_DIR}"
- cat "${TMP_FILELIST}" | cpio --quiet -o0 -H newc | gzip -9c > "${DEST}" || exit 1
+ if [ -e "${EXCLUDE_LIST}" ]
+ then
+ # Convert \0 to \n and tag existing (rare but possible) \n in filenames,
+ # this to let grep -F -v do a proper work in filtering out
+ cat "${TMP_FILELIST}" | tr '\n' '\1' | tr '\0' '\n' | grep -F -v -f "${EXCLUDE_LIST}" | tr '\n' '\0' | tr '\1' '\n' | cpio --quiet -o0 -H newc | gzip -9c > "${DEST}" || exit 1
+ else
+ cat "${TMP_FILELIST}" | cpio --quiet -o0 -H newc | gzip -9c > "${DEST}" || exit 1
+ fi
cd "${OLDPWD}"
;;
+ # ext2|ext3 and jffs2 does not support easely an exclude list, files should be copied in another directory in order to filter content
ext2|ext3)
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...
--- /dev/null
+# /etc/live-snapshot.exclude_list example
+#
+# If this file is present in the proper path, each uncommented not empty line
+# will be excluded in the target snapshot when live-snapshot is run.
+#
+# The syntax for the line is just a full file or directory pathname.
+
+# Each line is treated like a plain match string for "grep -F -v",
+# so be careful: e.g. "/tmp" will exclude also "/var/tmp" !
+
+# Exclude some standard temporary paths
+/tmp
+/var/log
+/var/cache
+
+# Firefox profiles are not always useful to remember
+/root/.mozilla
/etc/live-snapshot.list
-This optional file, if present changes the behaviour of live-snapshot, only files and directories listed there are included (integrally) in the snapshot.
-Beware, it is an experimental feature that only works for cpio targets now.
+This optional file, if present changes the behaviour of live-snapshot, only files and directories listed there are included (integrally) in the snapshot. It works only for cpio targets.
+
+ /etc/live-snapshot.exclude_list
+
+This optional file, if present will filter the files that will be saved by live-snapshot removing (as in "grep -F -v") all filenames that will be matched by strings listed in it.
+It works for cpio and squashfs snapshot types only; it is pretty useful for filtering temporary files and disk caches.
+
See also
--------
/etc/live-snapshot.list
Facoltativo, se presente cambia completamente il funzionamento di live-snapshot; solo i files e le directory elencate verranno effettivamente inclusi nello snapshot.
-Attenzione, e` una funzionalita` sperimentale che funziona attualmente solo con gli snapshot di tipo "cpio".
+Funziona attualmente solo con gli snapshot di tipo "cpio".
+ /etc/live-snapshot.exclude_list
+
+Facoltativo, se presente verrà utilizzato per filtrare i file da includere negli snapshot. Tutte i file che conterranno le stringhe elecate (come "grep -F -v") non verranno salvati da live-snapshot.
+Funziona attualmente solo con gli snapshot di tipo "cpio" e "squashfs"; è utile per filtrare contenuti poco significativi come i file temporanei e la cache.
See also
--------
# homecow just mount something on /home, this should be generalized some way
homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
- # This second type should be removed when snapshot grow smarter
+ # This second type should be removed when snapshot will get smarter,
+ # hence when "/etc/live-snapshot*list" will be supported also by
+ # ext2|ext3|jffs2 snapshot types.
home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
if [ -b "${cowprobe}" ]