Sat Apr 06, 2013 12:05 am
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} \
Sat Apr 06, 2013 1:02 pm
> kernel_image="${work_dir}/myfs/vmlinuz"
> initrd_image="${work_dir}/myfs/initrd.img"
# Let iso/, vmlinuz and initrd.img get copied, even if work_dir was saved,
# in case they have changed, unless $nocopy = yes.
copy_kernel () {
rsync -a "$iso_dir"/ "$work_dir"/iso/
cp "$kernel_image" "$work_dir"/iso/live/
cp "$initrd_image" "$work_dir"/iso/live/
}
# Copy the filesystem
copy_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_kernel
copy_filesystem
fi
Sun Apr 07, 2013 1:09 am
I think this should cause errors with the cp command trying to copy a file to itself. Are you seeing that, and if so, is it a problem?
# nocopy mode
kernel_image="$(ls ${work_dir}/myfs/boot|grep -m 1 vmlinuz)"
initrd_image="$(ls ${work_dir}/myfs/boot|grep -m 1 initrd)"
# later
cp ${work_dir}/myfs/boot/${kernel_image} ${work_dir}/iso/live/vmlinuz
cp ${work_dir}/myfs/boot/${initrd_image} ${work_dir}/iso/live/initrd.img
Sun Apr 07, 2013 1:34 pm
# @@@@ Warning: This will replace these files in custom iso_dir @@@@@
#copy some isolinux stuff from the system to the snapshot
rsync -a /usr/lib/syslinux/isolinux.bin "$iso_dir"/isolinux/
rsync -a /usr/lib/syslinux/vesamenu.c32 "$iso_dir"/isolinux/
Sun Apr 07, 2013 3:07 pm
Mon Apr 08, 2013 1:05 am
# Prepend the dir name with a constant,
# so you can find and delete the old ones
# that might have different snapshot basenames.
dir_prefix="pkglist"
rm -r "$work_dir"/iso/"$dir_prefix"*
mkdir -p "$work_dir"/iso/"${dir_prefix}_${filename%.iso}"
dpkg -l | grep "ii" | awk '{ print $2 }' > "$work_dir"/iso/"${dir_prefix}_${filename%.iso}"/package_list
# Prepend the dir name with a constant,
# so you can find and delete the old ones
# that might have different snapshot basenames.
dir_prefix="pkglist"
rm -r "$work_dir"/iso/"$dir_prefix"*
mkdir -p "$work_dir"/iso/"${dir_prefix}_${filename%.iso}"
if [[ $nocopy = "yes" ]] ; then
chroot "$work_dir" dpkg -l | grep "ii" | awk '{ print $2 }' > "$work_dir"/iso/"${dir_prefix}_${filename%.iso}"/package_list
else
dpkg -l | grep "ii" | awk '{ print $2 }' > "$work_dir"/iso/"${dir_prefix}_${filename%.iso}"
fi
Mon Apr 08, 2013 1:13 am
# The real work starts here
cd "$work_dir"
# @@@@ Warning: This will replace these files in custom iso_dir @@@@@
#copy some isolinux stuff from the system to the snapshot
copy_isolinux () {
rsync -a /usr/lib/syslinux/isolinux.bin "$iso_dir"/isolinux/
rsync -a /usr/lib/syslinux/vesamenu.c32 "$iso_dir"/isolinux/
}
# Let iso/, vmlinuz and initrd.img get copied, even if work_dir was saved,
# in case they have changed, unless $nocopy = yes.
copy_kernel () {
rsync -a "$iso_dir"/ "$work_dir"/iso/
cp "$kernel_image" "$work_dir"/iso/live/
cp "$initrd_image" "$work_dir"/iso/live/
}
# Copy the filesystem
copy_filesystem () {
rsync -av / myfs/ --delete-excluded --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_isolinux
copy_kernel
copy_filesystem
fi
if [[ $nocopy = "yes" ]] ; then
edit_boot_menu="yes"
fi
Mon Apr 08, 2013 2:41 pm
Tue Apr 09, 2013 1:58 pm
* Added test for remote, unmounted snapshot_dir or work_dir
* Added more items to excludes, especially root's hidden files.
* Changed rsync option '--delete' to '--delete-excludes'
* Added nocopy option to bypass rsync.
refractasnapshot -n
Tue Sep 03, 2013 9:00 am