Cleaned a bit the snapshot feature.
authorMarco Amadori <amadorim@vdavda.com>
Fri, 15 May 2009 16:05:08 +0000 (18:05 +0200)
committerDaniel Baumann <daniel@debian.org>
Fri, 15 May 2009 20:26:14 +0000 (22:26 +0200)
* home-sn are working both cpio and full partition, changed how
  live-snapshot.list works in home-sn case.

Signed-off-by: Marco Amadori <amadorim@vdavda.com>
bin/live-snapshot
conf/live-snapshot.list
manpages/live-snapshot.en.1.txt
manpages/live-snapshot.it.1.txt

index d70ef36..bf63041 100755 (executable)
@@ -238,7 +238,7 @@ Defaults ()
        # Parse resync string
        if [ -n "${SNAP_RESYNC_STRING}" ]
        then
-               SNAP_COW=$(echo "${SNAP_RESYNC_STRING}" | cut -f1 -d ':')
+               SNAP_COW=$(echo "${SNAP_RESYNC_STRING/\/root/${DEF_SNAP_COW}}" | cut -f1 -d ':')
                SNAP_DEV=$(echo "${SNAP_RESYNC_STRING}" | cut -f2 -d ':')
                SNAP_MNT=$(echo "${SNAP_RESYNC_STRING}" | cut -f3 -d ':')
                DEST="${MOUNTP}/${SNAP_MNT}"
@@ -346,7 +346,7 @@ Entry_is_modified ()
 
        if [ -e "${entry}" ] || [ -L "${entry}" ]
        then
-               if [ -e "${DEF_SNAP_COW}/${entry}" ] || [ -L "${DEF_SNAP_COW}/${entry}" ]
+               if [ -e "${SNAP_COW}/${entry}" ] || [ -L "${SNAP_COW}/${entry}" ]
                then
                        return 0
                fi
@@ -356,17 +356,25 @@ Entry_is_modified ()
 
 Do_filelist ()
 {
-       # BUGS: supports only cpio.gz types, and does not handle deleted files yet
-
+       # BUGS: does not handle deleted files yet
        TMP_FILELIST=$1
+
        if [ -f "${SNAP_LIST}" ]
        then
+               # if SNAP_COW == /live/cow/home, SNAP_RW = /home
+               SNAP_RW="${SNAP_COW/${DEF_SNAP_COW}}"
+               if [ -z "${SNAP_RW}" ]
+               then
+                       SNAP_RW="/"
+               fi
+
+               cd "${SNAP_RW}"
                # Generate include list removing empty and commented lines
-               for entry in $(sed -e '/^ *$/d' -e '/^#.*$/d' "${SNAP_LIST}")
+               # and transforming paths to relatives
+               for entry in $(sed -e '/^ *$/d' -e '/^#.*$/d' -e 's#^.*$#./&#' -e 's#/\+#/#g' "${SNAP_LIST}")
                do
                        if [ -d "${entry}" ]
                        then
-                               cd /
                                find "${entry}" | while read line
                                do
                                        if Entry_is_modified "${line}"
@@ -374,26 +382,22 @@ Do_filelist ()
                                                printf "%s\000" "${line}" >> "${TMP_FILELIST}"
                                        fi
                                done
-                               cd "${OLDPWD}"
                        elif Entry_is_modified "${entry}"
                        then
                                # if file exists and it is modified
                                printf "%s\000" "${entry}" >> "${TMP_FILELIST}"
                        fi
                done
+               cd "${OLDPWD}"
 
-               if [ "${SNAP_COW}" = "${DEF_SNAP_COW}" ]
-               then
-                       # Relative to rootfs
-                       echo "/"
-               else
-                       # Mostly "/home"
-                       echo "${SNAP_COW}"
-               fi
+               # echo Working dir
+               echo "${SNAP_RW}"
        else
                cd "${SNAP_COW}"
+               # removing whiteouts from list
                find . -path '*.wh.*' -prune -o -print0 >> "${TMP_FILELIST}"
                cd "${OLDPWD}"
+               # echo Working dir
                echo "${SNAP_COW}"
        fi
 }
index 30fe29d..db05733 100644 (file)
@@ -5,6 +5,8 @@
 #
 # The syntax for the line is just a full file or directory pathname.
 # Those files and directories, and only those will be included on automatic persistence handling.
+#
+# Note that in home-sn snapshot all those paths are treated as relative to /home
 
 # Include itself for reuse
 /etc/live-snapshot.list
index 4ead532..4f53e7e 100644 (file)
@@ -82,12 +82,12 @@ 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. It works only for cpio targets.
+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 and whole partition 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.
+It works for cpio, whole partition and squashfs snapshot types only; it is pretty useful for filtering temporary files and disk caches.
 
 
 See also
index dc8a992..1beb791 100644 (file)
@@ -89,12 +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.
-Funziona attualmente solo con gli snapshot di tipo "cpio".
+Funziona attualmente solo con gli snapshot di tipo "cpio" e "partizione intera".
 
   /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.
+Funziona attualmente solo con gli snapshot di tipo "cpio", "partizione intera" e "squashfs"; è utile per filtrare contenuti poco significativi come i file temporanei e la cache.
 
 See also
 --------