[SCM] Debian Live initramfs hook branch, master, updated. 1.139.1-3-14-gbb27306

Marco Amadori amadorim at vdavda.com
Wed Oct 1 00:05:26 UTC 2008


The following commit has been merged in the master branch:
commit d4478ba49dd0c2e41db3caccf4f4093cbea00e7a
Author: Marco Amadori <marco.amadori at gmail.com>
Date:   Sun Sep 28 00:07:22 2008 +0200

    Implemented a snapshot exclude list.
    
    * This finally enables one of the most requested feature to exclude
      things like disk caches and temporary files from the snapshots, just
      by editing "/etc/live-snapshot.exclude_list".
      This only works for cpio targets and for squashfs creations.
    
    Signed-off-by: Marco Amadori <marco.amadori at gmail.com>

diff --git a/bin/live-snapshot b/bin/live-snapshot
index 5606436..5a7b979 100755
--- a/bin/live-snapshot
+++ b/bin/live-snapshot
@@ -63,6 +63,7 @@ SNAP_OUTPUT=""
 SNAP_RESYNC_STRING=""
 SNAP_TYPE="cpio"
 SNAP_LIST="/etc/live-snapshot.list"
+EXCLUDE_LIST="/etc/live-snapshot.exclude_list"
 
 Error ()
 {
@@ -392,6 +393,13 @@ Do_snapshot ()
 			# 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}"
 			;;
@@ -399,10 +407,18 @@ Do_snapshot ()
 		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...
diff --git a/conf/live-snapshot.exclude_list b/conf/live-snapshot.exclude_list
new file mode 100644
index 0000000..82972e3
--- /dev/null
+++ b/conf/live-snapshot.exclude_list
@@ -0,0 +1,17 @@
+# /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
diff --git a/manpages/live-snapshot.en.1.txt b/manpages/live-snapshot.en.1.txt
index f57413d..e2c6241 100644
--- a/manpages/live-snapshot.en.1.txt
+++ b/manpages/live-snapshot.en.1.txt
@@ -82,8 +82,13 @@ Files
 
   /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
 --------
diff --git a/manpages/live-snapshot.it.1.txt b/manpages/live-snapshot.it.1.txt
index fd1ac04..dc8a992 100644
--- a/manpages/live-snapshot.it.1.txt
+++ b/manpages/live-snapshot.it.1.txt
@@ -89,8 +89,12 @@ Files
   /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
 --------
diff --git a/scripts/live b/scripts/live
index 8761138..5be6fe2 100755
--- a/scripts/live
+++ b/scripts/live
@@ -1155,7 +1155,9 @@ setup_unionfs ()
 		# 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}" ]

-- 
Debian Live initramfs hook



More information about the debian-live-changes mailing list