For example my current Wheezy system. When it was fairly new I made a snapshot. Now I want the live-image updated and tailored specifically for mobile use (not in the same way as the current running system) This involves some manual additions/deletions and chroot for apt stuff (including dist-upgrade)
Previously this was done manually or with custom scripts. However refracta snapshot itself can have a "nocopy" option with some quite minor code additions. Posted is a diff against 9.0.8-2 showing what I did.
- Code: Select all
179a180,185
>
> else
> if [ "$nocopy" = "yes" ]; then
> $DIALOG --$ERROR --title="Refracta Snapshot" --text=" Error.. No saved filesystem copy was found.. "
> exit 1
> fi
190a197
>
196a204,220
>
> # Don't use /media/* for $snapshot_dir unless it is a mounted filesystem
> snapdir_is_remote=$(echo ${snapshot_dir}| awk -F / '{print "/" $2 "/" $3}' |grep /media/)
>
> if [ -n "$snapdir_is_remote" ] && cat /proc/mounts|grep -q ${snapdir_is_remote}; then
> echo "$snapdir is mounted"
> else
> $DIALOG --$ERROR --title="Refracta Snapshot" --text=" Error.. The selected snapshot work directory cannot be accessed.. "
> exit 1
> fi
>
>
> if [ "$nocopy" = "yes" ]; then
> return
> fi
>
>
278c302
< $DIALOG --$INFO --text="Excludes file was set to default values.
---
> $DIALOG --$INFO --title="Refracta Snapshot" --text="Excludes file was set to default values.
281c305
< $DIALOG --$WARNING --text="Something went wrong. You should check your excludes file.
---
> $DIALOG --$WARNING --title="Refracta Snapshot" --text="Something went wrong. You should check your excludes file.
296a321
> FALSE 04 "Use a previously saved filesystem copy." \
309a335,342
>
> if $(echo $opts | grep -q 04); then
> nocopy="yes"
> save_work="yes"
> kernel_image="${work_dir}/myfs/vmlinuz"
> initrd_image="${work_dir}/myfs/initrd.img"
> fi
>
335c368
< $DIALOG --$INFO --text="This may take a moment while the program checks for free space. "
---
> $DIALOG --$INFO --title="Refracta Snapshot" --text="This may take a moment while the program checks for free space. "
347a381,383
>
> copy_filesystem () {
>
352a389,401
> # Copy the filesystem
> rsync -av / myfs/ --delete --exclude="$work_dir" \
> --exclude="$snapshot_dir" --exclude-from="$snapshot_excludes" \
> | tee >($DIALOG --title="Copying filesystem..." --progress --pulsate --width 300)
> kill $(pgrep $DIALOG)
>
> }
>
>
> if ! [ "$nocopy" = "yes" ]; then
> copy_filesystem
> fi
>
361,367d409
< # Copy the filesystem
< rsync -av / myfs/ --delete --exclude="$work_dir" \
< --exclude="$snapshot_dir" --exclude-from="$snapshot_excludes" \
< | tee >($DIALOG --title="Copying filesystem..." --progress --pulsate --width 300)
< kill $(pgrep $DIALOG)
<
<
428c470
< $DIALOG --$QUESTION --title=Edit Boot Menu --${BUTTON0}="Yes"${BUTTON0NUM} --${BUTTON1}="No"${BUTTON1NUM} \
---
> $DIALOG --$QUESTION --title="Edit Boot Menu" --${BUTTON0}="Yes"${BUTTON0NUM} --${BUTTON1}="No"${BUTTON1NUM} \
Another advantage: The original snapshot was 3.5 GB. After dealing manually with some excess stuff which is probably beyond the reasonable scope of snapshot's rsync-exclude list I got it down to 1.1 GB (amazing what lurks in those hidden "dot" files)
One word of warning to anyone who tries this.. Be careful what and how you delete, there might be symlinked directories to outside the saved FS in (most likely but could be elsewhere) $FS/home.. "rm -rf" horror stories are well documented elsewhere.
Note also my patch is "experimental" (tested here and one time only with zero guarantee against data loss) however the idea at least might be a useful addition to official Refractasnapshot. It includes a few other things like fixing some dialog windows that didn't display well and a check for, if a custom "work" dir on another filestem is used, it is actually plugged and mounted.