Ask your questions here.
Post a reply
golinux

- golinux
- Posts: 663
- Joined: Thu Nov 08, 2012 1:23 am

## [SOLVED] Squeeze snapshot

Fri Mar 22, 2013 11:53 pm

I finally got around to taking a snapshot of my squeeze/gnome system. / and /home partitions including all apps and files totals about 155GB. So I went through the snapshot_exclude.list very carefully to get rid of as much as possible. Even at that, the snapshot iso came to 22.7gb. (I can post the package list if you're interested.) What exactly am I supposed to do with that? Would that big an iso even work? I need to preserve my squeeze media apps because so far wheezy just isn't cutting it.
And one question about the excludes . . .
What's the diff between - /home/user/Videos/* and - /home/*/Videos/* ?
Last edited by golinux on Tue Apr 02, 2013 9:55 pm, edited 1 time in total.
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: Squeeze snapshot

Sat Mar 23, 2013 1:35 am

There was a discussion about big iso files awhile ago. squashfs-larger-than-4gb-t172.html
I think the biggest one made was around 6gb. If you have virtualbox or qemu installed, you can try to boot the iso file to test it. If you mount the iso, you can copy the contents to a partition on a hard drive (or a large usb thumb drive) and have a live system, From there, you could do a normal installation to hard drive.
- /home/user/video would exclude the video subdirectory inside the home directory of the user named user.
- /home*/video would also exclude Buford's video directory along with any other users who had a video directory in their home, and if they existed, /home/clamav/video and /home/github/video. (/home/snapshot/video would already be excluded, because the snapshot directory is excluded.)
nadir

- nadir
- Posts: 1160
- Joined: Wed Mar 09, 2011 4:18 am
- Location: here

## Re: Squeeze snapshot

Sat Mar 23, 2013 5:23 am

- /home/you/*
will remove or exclude all visible folders (if you got files at toplevel then those too)
I think. wildcards are good for surprises. excludes are good for surprises.
du -sh .[a-zA-Z0-9]*
will show the size of all hidden files and folders.
You can use a | to "sort" (if you find out how to get a useful result. I don't. I usually just use | grep M )
If some of them are outstanding big, for me .i2p is and in the past .Virtuablbox was, then you want to add it to the excludes list.
To check a bit more you can also do
du -sh /*
usr and var (and obviously home too) should be of big size, the rest not. Big means > Gig
I am pretty sure that all kind of stuff is excluded per default, so "apt-get clean" won't help (but won't hurt neither).
I think that is the reason. Some visual folders from your home missing in the excludes list. No usual installation should be bigger than 10 Gigs (I never fooled with multimedia, but i really got bloated installations and none is bigger than 6 Gigs)
If it really is that big, then i got no idea (but fsmithred had already)
I sometimes safe stuff at /root, forget it, and that gives me big size.
Yes, post your list. Perhaps, if unsure, post "ls -l /home/you" too.
Not sure if it helps you: I can't say that for me excluding works out of box neither. Always a bit of trying (or asking others).
ukbrian

- ukbrian
- Posts: 109
- Joined: Mon Jul 25, 2011 8:22 am
- Location: Cheltenham, UK

## Re: Squeeze snapshot

Sat Mar 23, 2013 12:19 pm

Anthony Nordquist(SalineOS wrote a backup script for Squeeze quite a time ago that wrote a backup file rather than an ISO to overcome the ISO size limitations.
With his original script you could point at any installed OS to create a backup file but he had a bad experience I think trying to backup a Fedora OS so with his later script he restricted it to only backup the OS your running it on.
I made a qt4-fsarchiver rescue ISO with both the scripts on it which might be of use to you http://lin.me.uk/qt4-fsarchiver/iso/qt4-5.5-20120630_1955.iso as you can backup/restore from the ISO.
I don't think there's an exclude section so it might take a time to do your backup.
The backup script or option you need is the desktop icon labelled "Saline Backup V1" on the ISO or the script is at http://lin.me.uk/qt4-fsarchiver/iso/saline-backup-1
Because the backup file is not an ISO you need to do the restore from a running OS or the ISO
You might find the "Saline Backup V2" script better for restoring as it displays partition labels which I find very helpful when you have multiple partitions.
The script lives at /usr/bin

Code:
  `#!/bin/bash
  # Licensed under the GNU General Public License Version 2
  #
  # This program is free software; you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
  # the Free Software Foundation; either version 2 of the License, or
  # (at your option) any later version.
  #
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  # GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  ####################################################################################################
  # Copyright 2008,2009,2010,2012 Under the GNU GPL2 License
  # Authors Tony Brijeski, Anthony Nordquist http://www.salineos.com [email protected]
  ## Set options for yet another dialog, this makes creating dialogs much easier.
  Info='yad --center --title=SalineOS-Backup --window-icon=/usr/share/pixmaps/salineos-backup.png'
  Question='yad --wrap --center --image=gtk-dialog-question --button=gtk-no:1 --button=gtk-yes:0 --title=SalineOS-Backup --window-icon=/usr/share/pixmaps/salineos-installer.png'
  SingleMenu='yad --center --list --column=Choices --title=SalineOS-Backup --window-icon=/usr/share/icons/pixmaps/salineos-installer.png'
  Menu='yad --print-column=1 --center --list --title=SalineOS-Backup --window-icon=/usr/share/pixmaps/salineos-installer.png'
  Progress='yad --center --progress --auto-close --title=SalineOS-Backup --no-buttons --window-icon=/usr/share/pixmaps/salineos-installer.png'
  TextEntry='yad --center --entry --title=SalineOS-Backup --window-icon=/usr/share/pixmaps/salineos-installer.png'
  StartBackup () {
  SaveFolder=$(yad --file-selection --title="SalineOS-Backup" --height=450 --width=600 --directory --text="\n Select the folder to save the backup image to\n" --button=$"gtk-quit:3" --button=$"gtk-ok:2")
  ret="$?"
  if [ "$ret" = "252" ]; then
  StartBackup
  exit 0
  elif [ "$ret" = "3" ]; then
  exit 0
  elif [ "$SaveFolder" = "" ]; then
  StartBackup
  exit 0
  fi
  ImageName=$($TextEntry --wrap --width=250 --text="Enter a name for the backup file, or select time to use the current time and date." --button=$"gtk-quit:3" --button=$"Time:5" --button=$"gtk-ok:2")
  ret="$?"
  #added
  #ImageName=$(date +%Y%m%d-%H%M)
  #print $ImageName
  if [ "$ret" = "252" ]; then
  exit 0
  elif [ "$ret" = "3" ]; then
  exit 0
  elif [ "$ret" = "5" ]; then
  ImageName=$(date +%Y%m%d-%H%M)
  elif [ "$ImageName" = "" ]; then
  ImageName=SalineOS
  ImageName=($ImageName_$(date +%Y%m%d-%H%M))
  fi
  if [ "$BackupPart" = "root" ]; then
  $Info --text="Please close all other running applications before continuing and refrain from opening any applications until this operation has completed." --wrap --width=250 --button=$"gtk-ok:1"
  UseRoot='/'
  elif [ "$(mount | grep "$BackupPart" | awk '{print $3}')" != "" ]; then
  $Info --text="Please close all other running applications before continuing and refrain from opening any applications until this operation has completed." --wrap --width=250 --button=$"gtk-ok:1"
  UseRoot="$(mount | grep "$BackupPart" | awk '{print $3}')"
  if [ "$HomePart" != "" ]; then
  HomeMountPoint="$(mount | grep "$HomePart" | awk '{print $3}')"
  if [ "$HomeMountPoint" != "" ]; then
  umount "$HomePart"
  umount -l "$HomePart"
  if [ "$(echo "$SaveFolder" | grep "$HomeMountPoint")" != "" ]; then
  SaveFolder=$(echo "$SaveFolder" | sed -u "s|"$HomeMountPoint"|"$UseRoot"/home|g")
  fi
  fi
  mount "$HomePart" "$UseRoot/home" -o rw
  fi
  else
  mkdir -p /mnt/Super-Happy-Mount-Point
  mount "$BackupPart" /mnt/Super-Happy-Mount-Point -o rw
  UseRoot="/mnt/Super-Happy-Mount-Point"
  if [ "$HomePart" != "" ]; then
  HomeMountPoint="$(mount | grep "$HomePart" | awk '{print $3}')"
  if [ "$HomeMountPoint" != "" ]; then
  umount "$HomePart"
  umount -l "$HomePart"
  if [ "$(echo "$SaveFolder" | grep "$HomeMountPoint")" != "" ]; then
  SaveFolder=$(echo "$SaveFolder" | sed -u "s|"$HomeMountPoint"|"$UseRoot"/home|g")
  fi
  fi
  mount "$HomePart" /mnt/Super-Happy-Mount-Point/home -o rw
  fi
  fi
  /usr/bin/time --output=/tmp/TimeTaken -p mksquashfs "$UseRoot" "$SaveFolder/$ImageName.backup" -always-use-fragments -b 1M -no-duplicates -no-recovery -e \
  .bash_history \
  .cache \
  .thumbnails \
  boot/grub \
  Cache \
  media \
  "$SaveFolder/$ImageName.backup" \
  mnt \
  proc \
  swap \
  sys \
  tmp \
  var/run\>>/tmp/salineos-backup-temp-file &
  sleep 1
  (while [ "$(pidof mksquashfs)" != "" ]; do
  CurrentOutput="$(tail --lines=1 /tmp/salineos-backup-temp-file)"
  echo "$CurrentOutput" | awk -F ' ' '{print $NF}' | awk -F '%' '{print $1}'
  done)| $Progress --text="Creating backup image $ImageName.backup, Please wait..."
  ## Let all users move the file around
  chmod o+rwx "$SaveFolder/$ImageName.backup"
  ls /home>>/tmp/salineos-backup-home-list
  UserNameTemp=$(tail --lines=1 /tmp/salineos-backup-home-list)
  chown "$UserNameTemp" "$SaveFolder/$ImageName.backup"
  ## Unmount partitions if needed
  if [ "$HomePart" != "" ]; then
  umount "$HomePart"
  fi
  if [ "$BackupPart" != "root" ]; then
  umount "$BackupPart"
  fi
  ## Cleanup some
  if [ -d /mnt/Super-Happy-Mount-Point ]; then
  rm -rf /mnt/Super-Happy-Mount-Point
  fi
  TimeTaken=$(($(grep "real" /tmp/TimeTaken | awk '{print $2}' | awk -F '.' '{print $1}') / 60))
  rm /tmp/TimeTaken
  rm /tmp/salineos-backup-temp-file
  $Info --text="Creation of backup image "$ImageName.backup" complete.\nImage saved to directory $SaveFolder\nThis operation took "$TimeTaken" minutes." --button=$"gtk-quit:1"
  exit 0
  }
  SelectBackupHomePart () {
  PartMenu=""
  Partitions=$(cat /proc/partitions | awk '{print $4}' | grep "[0-9]" | grep -v 'p1' | grep -v "$BackupPart")
  TempParts="$(echo $Partitions)"
  for i in $Partitions; do
  TempSize=$(grep -m 1 "$i" /proc/partitions | awk '{print $3}')
  if [ "$TempSize" = "1" ]; then
  TempParts=$(echo $TempParts | sed -r "s/$i//")
  fi
  done
  for i in $TempParts; do
  Part="$i"
  PartSize=$(grep -m 1 "$i" /proc/partitions | awk '{print $3}')
  PartMenu="$PartMenu $Part $PartSize"
  done
  HomePart=$($Menu --height=300 --width=300 --wrap --column="Partition Name" --column="Size In Megabytes" --button=$"gtk-quit:3" --button=$"Use Selected:2" --text="Please select the home partition for "$BackupPart"." $PartMenu )
  ret=$?
  if [ "$ret" = "252" ]; then
  SelectBackupHomePart
  exit 0
  elif [ "$ret" = "3" ]; then
  exit 0
  elif [ "$HomePart" = "" ]; then
  SelectBackupHomePart
  exit 0
  fi
  HomePart=$(echo "$HomePart" | awk -F '|' '{print $1}')
  HomePart="/dev/$HomePart"
  StartBackup
  }
  SelectBackupPart () {
  PartMenu=""
  Partitions=$(cat /proc/partitions | awk '{print $4}' | grep "[0-9]" | grep -v 'p1')
  TempParts="$(echo $Partitions)"
  for i in $Partitions; do
  TempSize=$(grep -m 1 "$i" /proc/partitions | awk '{print $3}')
  if [ "$TempSize" = "1" ]; then
  TempParts=$(echo $TempParts | sed -r "s/$i//")
  fi
  done
  for i in $TempParts; do
  Part="$i"
  PartSize=$(grep -m 1 "$i" /proc/partitions | awk '{print $3}')
  PartMenu="$PartMenu $Part $PartSize"
  done
  BackupPart=$($Menu --height=300 --width=300 --wrap --column="Partition Name" --column="Size In Megabytes" --button=$"gtk-quit:3" --button=$"Use Selected:2" --text="Please select the root partition you want to backup." $PartMenu )
  ret=$?
  if [ "$ret" = "252" ]; then
  SelectBackupPart
  exit 0
  elif [ "$ret" = "3" ]; then
  exit 0
  elif [ "$BackupPart" = "" ]; then
  SelectBackupPart
  exit 0
  fi
  BackupPart=$(echo "$BackupPart" | awk -F '|' '{print $1}')
  BackupPart="/dev/$BackupPart"
  $Question --text="Is /home for this instance on a seperate partition?"
  if [ "$?" = "0" ]; then
  $Info --wrap --width=250 --button=$"gtk-quit:3" --button=$"gtk-ok:1" --text="If the /home folder for "$BackupPart" is shared with SalineOS, then you will have to run SalineOS backup from a live environment."
  ret=$?
  if [ "$ret" = "3" ]; then
  exit 0
  else
  SelectBackupHomePart
  fi
  else
  StartBackup
  fi
  }
  RunInstallation () {
  tail -f /usr/bin/salineos-backup | $Progress --pulsate --text=" Preparing disk and partitions " &
  if [ "$Input" = "ext3" ]; then
  FilesystemType="ext3"
  else
  FilesystemType="ext4"
  fi
  if [ "$AutoPart" = "Auto" ]; then
  parted --script --align optimal /dev/$PartDrive mklabel msdos
  parted --script --align optimal /dev/$PartDrive mkpart primary 1 -- -1
  parted --script --align optimal /dev/$PartDrive set 1 boot on
  TargetHomePart="root"
  TargetPart="$PartDrive"1
  fi
  if [ "$(mount | grep $TargetPart)" != "" ]; then
  umount /dev/$TargetPart
  sleep 3
  fi
  mke2fs -t $FilesystemType /dev/$TargetPart
  mkdir -p /Target
  sleep 3
  killall -KILL tail
  tail -f /usr/bin/salineos-backup | $Progress --pulsate --text=" Mounting $TargetPart " &
  mount /dev/$TargetPart /Target -o rw
  sleep 3
  killall -KILL tail
  tail -f /usr/bin/salineos-backup | $Progress --pulsate --text="Configure the filesystem to be checked\nevery 35 mounts" &
  tune2fs -c 35 -i 0 /dev/$TargetPart
  sleep 3
  rm -rf /Target/lost+found
  killall -KILL tail
  if [ "$TargetHomePart" != "root" ]; then
  if [ "$FormatHome" = "True" ]; then
  tail -f /usr/bin/salineos-backup | $Progress --pulsate --text=" Formatting $TargetHomePart for /home " &
  umount /dev/$TargetHomePart
  sleep 2
  mke2fs -t $FilesystemType /dev/$TargetHomePart
  sleep 3
  killall -KILL tail
  fi
  tail -f /usr/bin/salineos-backup | $Progress --pulsate --text=" Mounting $TargetHomePart " &
  mkdir -p /Target/home
  mount /dev/$TargetHomePart /Target/home -o rw
  tune2fs -c 35 -i 0 /dev/$TargetHomePart
  rm -rf /Target/home/lost+found
  TargetHomeUUID=$(blkid /dev/$TargetHomePart | awk -F 'UUID="' '{print $2}' | awk -F '"' '{print $1}')
  ## Get fs type for the home partition in case the user chose not to format it
  HomeFilesystemType=$(mount | grep "/dev/$TargetHomePart" | awk '{print $5}' | awk -F ' ' '{print $1}')
  killall -KILL tail
  fi
  tail -f /usr/bin/salineos-backup | $Progress --pulsate --text=" Generating UUID values for fstab " &
  TargetPartUUID=$(blkid /dev/$TargetPart | awk -F 'UUID="' '{print $2}' | awk -F '"' '{print $1}')
  TargetCDRom="/dev/cdrom"
  sleep 3
  killall -KILL tail
  ## Copy the live system to $Target
  tail -f /usr/bin/salineos-backup | $Progress --text=" Copying files to $TargetPart " --pulsate &
  ## Mount the backup image
  mkdir -p /mnt/Super-Happy-Mount-Point
  mount "$BackupImage" -o loop /mnt/Super-Happy-Mount-Point
  rsync -a /mnt/Super-Happy-Mount-Point/ /Target --ignore-existing --exclude=/{Target,live,cdrom,mnt,proc,sys,media}
  sleep 3
  ## Unmount backup image
  umount "/mnt/Super-Happy-Mount-Point"
  sleep 1
  ## Remove mount point
  rm -rf /mnt/Super-Happy-Mount-Point
  ## Make needed aditional folders on the system.
  mkdir -p /Target/{proc,dev,mnt,sys,tmp,media/cdrom}
  mkdir -p /Target/var/run
  sleep 3
  killall -KILL tail
  tail -f /usr/bin/salineos-backup | $Progress --text=" Setting up swap space " --pulsate &
  if [ "$UseSwapFile" = "True" ]; then
  mkdir -p /Target/swap
  fallocate --l "$SwapFileSize"m /Target/swap/salineos-swap
  sleep 2
  mkswap /Target/swap/salineos-swap
  SwapFstab="/swap/salineos-swap"
  else
  mkswap $Swap
  sleep 2
  blkid
  sleep 2
  TargetSwapUUID=$(blkid /dev/$Swap | awk -F 'UUID="' '{print $2}' | awk -F '"' '{print $1}')
  SwapFstab="UUID=$TargetSwapUUID"
  fi
  killall -KILL tail
  tail -f /usr/bin/salineos-backup | $Progress --text="Changing configuration files on installed system" --pulsate &
  ## Prepare a chroot envoirnment for post install changes
  mount -o bind /proc /Target/proc
  mount -o bind /dev /Target/dev
  mount -o bind /sys /Target/sys
  rm -rf /Target/etc/fstab
  ## Create a new fstab file for the system
  if [ "$TargetHomePart" = "root" ]; then
  cat > /Target/etc/fstab <<FOO
  # /etc/fstab: static file system information.
  #
  # <file system> <mount point> <type> <options> <dump> <pass>
  proc /proc proc defaults 0 0
  # Root was on /dev/$TargetPart during install
  UUID=$TargetPartUUID / $FilesystemType relatime,errors=remount-ro 0 1
  # Swap space created during install
  $SwapFstab none swap sw 0 0
  # cdrom
  $TargetCDRom /media/cdrom udf,iso9660 user,noauto,exec,utf8 0 0
  FOO
  else
  cat > /Target/etc/fstab <<FOO
  # /etc/fstab: static file system information.
  #
  # <file system> <mount point> <type> <options> <dump> <pass>
  proc /proc proc defaults 0 0
  # Root was on /dev/$TargetPart during install
  UUID=$TargetPartUUID / $FilesystemType relatime,errors=remount-ro 0 1
  # /dev/$TargetHomePart home
  UUID=$TargetHomeUUID /home $HomeFilesystemType relatime 0 0
  # Swap space created during install
  $SwapFstab none swap sw 0 0
  # cdrom
  $TargetCDRom /media/cdrom udf,iso9660 user,noauto,exec,utf8 0 0
  FOO
  fi
  ## Make the users on the system own their home folders
  for i in $(ls /Target/home); do
  chown -R "$i" /Target/home/"$i"
  done
  ## Fix permissions on /tmp
  chmod og+rw /Target/tmp
  sleep 3
  killall -KILL tail
  ## Install GRUB2
  tail -f /usr/bin/salineos-backup | $Progress --text=" Installing and configuring GRUB2 " --pulsate &
  chroot /Target chmod -x /etc/grub.d/20_memtest86+
  chroot /Target grub-install --force --no-floppy "$GrubLocation"
  sleep 2
  chroot /Target update-grub
  sleep 2
  killall -KILL tail
  ## Unmount the target partition
  tail -f /usr/bin/salineos-backup | $Progress --text=" Unmounting $TargetPart " --pulsate &
  sleep 2
  umount /Target/home
  sleep 2
  umount /Target/proc
  sleep 2
  umount /Target/dev
  sleep 2
  umount /Target/sys
  sleep 2
  umount /Target
  sleep 2
  ## Remove Target
  rm -rf /Target
  killall -KILL tail
  $Question --text="\nRestoration is complete.\n\nIf everything went well you should have your\nnew system installed and ready.\n\nDo you want to reboot now to try it out?"
  if [ $? = 0 ]; then
  reboot
  else
  exit 0
  fi
  }
  FinishedMenu () {
  Change=""
  if [ "$AutoPart" = "Manual" ]; then
  if [ "$UseSwapFile" = "True" ]; then
  SwapFinished='Swap-File'
  SwapFinished2="A $SwapFileSize Megabytes swap file will be created"
  else
  SwapFinished='Swap-Partition'
  SwapFinished2="$Swap will be used as the swap partition"
  fi
  RootPartition="Root-Partition"
  if [ "$Input" = "ext3" ]; then
  RootPartition2="$TargetPart will be formatted (erased) ext3 and used for root"
  else
  RootPartition2="$TargetPart will be formatted (erased) ext4 and used for root"
  fi
  HomePartFinished="Home"
  if [ "$TargetHomePart" = "root" ]; then
  HomePartFinished2="The home folder will be placed on the root partition"
  else
  if [ "$FormatHome" = "True" ]; then
  if [ "$Input" = "ext3" ]; then
  HomePartFinished2="$TargetHomePart will be formated (erased) ext3 and used for /home"
  else
  HomePartFinished2="$TargetHomePart will be formated (erased) ext4 and used for /home"
  fi
  else
  HomePartFinished2="$TargetHomePart will be used for /home without erasing data"
  fi
  fi
  else
  SwapFinished='Swap-File'
  SwapFinished2="A $SwapFileSize Megabytes swap file will be created"
  RootPartition="Use-Disk"
  RootPartition2="$PartDrive will be erased and the entire disk used"
  fi
  GrubFinished="Boot-Loader"
  GrubFinished2="The GRUB2 boot loader will be installed to "$GrubLoc""
  if [ "$AutoPart" = "Auto" ]; then
  Change=$($Menu --height=300 --column="Option" --column="Current Status" --text="Please review the settings you have chosen carefully, you may go back and change any \nof these settings now.\n" --button=$"gtk-quit:3" --button=$"Change Selected:2" --button=$"Run Installation:5" "$RootPartition" "$RootPartition2" "$SwapFinished" "$SwapFinished2" "$GrubFinished" "$GrubFinished2")
  else
  Change=$($Menu --height=300 --column="Option" --column="Current Status" --text="Please review the settings you have chosen carefully, you may go back and change any \nof these settings now.\n" --button=$"gtk-quit:3" --button=$"Change Selected:2" --button=$"Run Installation:5" "$RootPartition" "$RootPartition2" "$SwapFinished" "$SwapFinished2" "$HomePartFinished" "$HomePartFinished2" "$GrubFinished" "$GrubFinished2")
  fi
  ret="$?"
  Change=$(echo "$Change" | awk -F '|' '{print $1}')
  if [ "$ret" = "252" ]; then
  FinishedMenu
  exit 0
  elif [ "$ret" = "3" ]; then
  $Question --text="Are you sure you want to cancel the restoration?"
  if [ "$?" = "0" ]; then
  if [ -f /tmp/Finished-Menu ]; then
  rm /tmp/Finished-Menu
  fi
  exit 1
  else
  FinishedMenu
  exit 0
  fi
  elif [ "$ret" = "5" ]; then
  rm -rf /tmp/Finished-Menu
  RunInstallation
  exit 0
  elif [ "$Change" = "Swap-Partition" ]; then
  SelectSwapPart
  exit 0
  elif [ "$Change" = "Root-Partition" ]; then
  SelectRootPart
  exit 0
  elif [ "$Change" = "Swap-File" ]; then
  SwapFile
  exit 0
  elif [ "$Change" = "Home" ]; then
  SelectHomePart
  exit 0
  elif [ "$Change" = "Boot-Loader" ]; then
  GrubSelect
  exit 0
  elif [ "$Change" = "Use-Disk" ]; then
  ChooseDrive
  exit 0
  elif [ "$Change" = "" ]; then
  $Info --text="No change selected" --button=$"gtk-ok:1"
  FinishedMenu
  exit 0
  fi
  rm -rf /tmp/Finished-Menu
  }
  GrubSelect () {
  ## Grub location
  GrubLocation=""
  GrubLoc=""
  GrubLoc=$($Menu --width=300 --height=250 --column='Location' --column=' ' --button=$"gtk-quit:3" --button=$"gtk-ok:2" --text="Please select where to install the grub boot loader\n" $GrubMenu root "Root partition - (Advanced)")
  ret="$?"
  if [ "$ret" = "252" ]; then
  GrubSelect
  exit 0
  elif [ "$ret" = "3" ]; then
  $Question --text="Are you sure you want to cancel the restoration?"
  if [ "$?" = "0" ]; then
  if [ -f /tmp/Finished-Menu ]; then
  rm /tmp/Finished-Menu
  fi
  exit 1
  else
  GrubSelect
  exit 0
  fi
  elif [ "$GrubLoc" = "" ]; then
  $Info --text="The grub location cannot be blank, please choose where to install grub." --button=$"gtk-ok:1"
  GrubSelect
  exit 0
  fi
  GrubLoc=$(echo "$GrubLoc" | awk -F '|' '{print $1}')
  if [ "$GrubLoc" != "root" ]; then
  GrubLocation="/dev/$GrubLoc"
  else
  GrubLocation="/dev/$TargetPart"
  fi
  touch /tmp/Finished-Menu
  FinishedMenu
  }
  SelectHomePart () {
  HomePartMenu=""
  ExtraParts="$(fdisk -l | grep '/dev/' | grep -v "Disk" | grep -v "Extended" | grep -v "$TargetPart" | grep -v "swap" | grep -v 'p1' | grep -v "extended" | grep -v "Hidden" | cut -d " " -f1)"
  ## Cleanup the fdisk output
  HomeParts=$(echo "$ExtraParts" | sed -r "s/\/dev\///g")
  for i in $HomeParts; do
  HomePart="$i"
  HomePartSize=$(grep -m 1 "$i" /proc/partitions | awk '{print $3}')
  HomePartMenu="$HomePartMenu $HomePart $HomePartSize"
  done
  HomePart=$($Menu --text=" Select a seperate partition for /home (User files) if desired\n" --height=400 --column=Partition --column="Size in Megabytes" --button=$"gtk-quit:3" --button=$"Use Selected:2" --button=$"Put /home on the root partition:5" $HomePartMenu)
  ret=$?
  if [ "$ret" = "252" ]; then
  SelectHomePart
  exit 0
  elif [ "$ret" = "3" ]; then
  $Question --text="Are you sure you want to cancel the installation?"
  if [ "$?" = "0" ]; then
  if [ -f /tmp/Finished-Menu ]; then
  rm /tmp/Finished-Menu
  fi
  exit 1
  else
  SelectSwapPart
  exit 0
  fi
  elif [ "$ret" = "5" ]; then
  if [ -f /tmp/Finished-Menu ]; then
  TargetHomePart="root"
  FinishedMenu
  exit 0
  fi
  TargetHomePart="root"
  GrubSelect
  exit 0
  elif [ "$HomePart" = "" ]; then
  SelectHomePart
  exit 0
  else
  TargetHomePart=$(echo "$HomePart" | awk -F '|' '{print $1}')
  $Question --text="Format (Erase all data) on the target home partition, $TargetHomePart?"
  if [ "$?" = "0" ]; then
  FormatHome="True"
  else
  FormatHome="False"
  fi
  fi
  if [ -f /tmp/Finished-Menu ]; then
  FinishedMenu
  exit 0
  else
  GrubSelect
  exit 0
  fi
  }
  SelectSwapPart () {
  SwapPartMenu=""
  Swap=""
  ## Find swap partitions and find out which to use.
  TargetSwap=$(fdisk -l | grep "swap" | cut -d " " -f1)
  TargetSwap=$(echo "$TargetSwap" | sed -r "s/\/dev\///g")
  for i in $TargetSwap; do
  SwapPart="$i"
  SwapPartSize=$(grep -m 1 "$i" /proc/partitions | awk '{print $3}')
  SwapPartMenu="$SwapPartMenu $SwapPart $SwapPartSize"
  done
  Swap=$($Menu --width=300 --height=250 --text=" Please select the partition to use for swap\n" --column=Partition --column="Size in Megabytes" --button=$"gtk-quit:3" --button=$"Use Swap File:5" --button=$"Use Selected:2" $SwapPartMenu)
  ret=$?
  if [ "$ret" = "3" ]; then
  $Question --text="Are you sure you want to cancel the restoration?"
  if [ "$?" = "0" ]; then
  if [ -f /tmp/Finished-Menu ]; then
  rm /tmp/Finished-Menu
  fi
  exit 1
  else
  SelectSwapPart
  exit 0
  fi
  elif [ "$ret" = "252" ]; then
  SelectSwapPart
  exit 0
  elif [ "$ret" = "5" ]; then
  SwapFile
  exit 0
  elif [ "$Swap" = "" ]; then
  SelectSwapPart
  exit 0
  elif [ -f /tmp/Finished-Menu ]; then
  Swap=$(echo "$Swap" | awk -F '|' '{print $1}')
  FinishedMenu
  exit 0
  else
  HomePartTest="$(fdisk -l | grep '/dev/' | grep -v "Disk" | grep -v 'p1' | grep -v "Extended" | grep -v "$TargetPart" | grep -v "Swap")"
  if [ "$HomePartTest" != "" ]; then
  Swap=$(echo "$Swap" | awk -F '|' '{print $1}')
  SelectHomePart
  exit 0
  fi
  Swap=$(echo "$Swap" | awk -F '|' '{print $1}')
  GrubSelect
  exit 0
  fi
  }
  SwapFile () {
  SwapFileSize=""
  if [ "$AutoPart" = "Auto" ]; then
  SwapFileSize=$($Menu --column="Size" --column=" " --text=" Please select the size of the swap file to be created.\n" --button=$"Continue:2" 32 Megabytes 64 Megabytes 128 Megabytes 256 Megabytes 512 Megabytes 1024 Megabytes 2048 "Megabytes It is recommended to choose this setting" 3072 Megabytes 4096 Megabytes 5120 Megabytes 6144 Megabytes 8192 Megabytes 16384 Megabytes 30000 Megabytes --height=350 )
  else
  SwapFileSize=$($Menu --column="Size" --column=" " --text=" Please select the size of the swap file to be created.\n" --button=$"Use Swap Partition (Advanced):3" --button=$"Continue using swap file:2" 32 Megabytes 64 Megabytes 128 Megabytes 256 Megabytes 512 Megabytes 1024 Megabytes 2048 "Megabytes It is recommended to choose this setting" 3072 Megabytes 4096 Megabytes 5120 Megabytes 6144 Megabytes 8192 Megabytes 16384 Megabytes 30000 Megabytes --height=350 )
  fi
  ret=$?
  if [ "$ret" = "3" ]; then
  UseSwapFile="False"
  SelectSwapPart
  exit 0
  elif [ "$ret" = "252" ]; then
  SwapFile
  exit 0
  elif [ "$SwapFileSize" = "" ]; then
  SwapFile
  exit 0
  else
  UseSwapFile="True"
  SwapFileSize=$(echo "$SwapFileSize" | awk -F '|' '{print $1}')
  if [ -f /tmp/Finished-Menu ]; then
  FinishedMenu
  exit 0
  elif [ "$AutoPart" = "Auto" ]; then
  GrubSelect
  exit 0
  fi
  HomePartTest="$(fdisk -l | grep '/dev/' | grep -v "Disk" | grep -v 'p1' | grep -v "Extended" | grep -v "$TargetPart" | grep -v "Swap")"
  if [ "$HomePartTest" != "" ]; then
  SelectHomePart
  exit 0
  fi
  GrubSelect
  exit 0
  fi
  }
  ## Choose the partition to install to
  SelectRootPart () {
  PartMenu=""
  Partitions=$(cat /proc/partitions | grep "$PartDrive" | awk '{print $4}' | grep "[0-9]" | grep -v 'p1')
  InstallPart="$(echo $Partitions)"
  for i in $Partitions; do
  TempSize=$(grep -m 1 "$i" /proc/partitions | awk '{print $3}')
  if [ "$TempSize" = "1" ]; then
  InstallPart=$(echo $InstallPart | sed -r "s/$i//")
  fi
  done
  for i in $InstallPart; do
  Part="$i"
  PartSize=$(grep -m 1 "$i" /proc/partitions | awk '{print $3}')
  PartMenu="$PartMenu $Part $PartSize"
  done
  TargetPart=$($Menu --height=300 --width=300 --wrap --column="Partition Name" --column="Size In Megabytes" --button=$"gtk-quit:3" --button=$"Use Selected:2" --text="Please select a partition to install the root (Main) directory to.\n" $PartMenu )
  ret=$?
  if [ "$ret" = "252" ]; then
  SelectRootPart
  exit 0
  elif [ "$ret" = "3" ]; then
  $Question --text="Are you sure you want to cancel the restoration?"
  if [ "$?" = "0" ]; then
  if [ -f /tmp/Finished-Menu ]; then
  rm /tmp/Finished-Menu
  fi
  exit 1
  else
  SelectRootPart
  exit 0
  fi
  elif [ "$TargetPart" = "" ]; then
  SelectRootPart
  exit 0
  fi
  TargetPart=$(echo "$TargetPart" | awk -F '|' '{print $1}')
  ## Since unlike the salineos-installer this utility can be run from a non live envoirnment
  ## We need to make sure that the user doesn't try to install to the current partition
  RootDir="$(mount | grep -B 0 ' / ')"
  if [ "$(echo "$RootDir" | grep "$TargetPart")" != "" ]; then
  $Info --wrap --width=300 --text="You cannot erase the partition this utility is running from, please select another partition to install to, or run this utility from a live environment.\n"
  SelectRootPart
  fi
  if [ -f /tmp/Finished-Menu ]; then
  FinishedMenu
  exit 0
  else
  SwapFile
  exit 0
  fi
  }
  ## Choose the drive to partition
  ChooseDrive () {
  GrubMenu=""
  PartDriveMenu=""
  PartDrive=""
  Drives=$(cat /proc/partitions | grep -v loop | grep -v major | grep -v "^$" | awk '{print $4}' | grep -v "[0-9]")
  for i in $Drives; do
  PartDrive="$i"
  PartDriveSize=$(grep -m 1 "$i" /proc/partitions | awk '{print $3}')
  PartDriveMenu="$PartDriveMenu $PartDrive $PartDriveSize"
  GrubMenu="$PartDrive Master-Boot-Record $GrubMenu"
  done
  if [ "$AutoPart" = "Auto" ]; then
  PartDrive=$($Menu --width=300 --height=300 --column="Drive" --column="Size In Megabytes" --text="Please select a drive to erase and use.\n" --button=$"gtk-quit:3" --button=$"gtk-ok:2" $PartDriveMenu )
  else
  PartDrive=$($Menu --width=300 --height=300 --column="Drive" --column="Size In Megabytes" --text="Please select a drive to partition.\n" --button=$"gtk-quit:3" --button=$"gtk-ok:2" $PartDriveMenu )
  fi
  ret=$?
  if [ "$ret" = "3" ]; then
  $Question --text="Are you sure you want to cancel the resoration?"
  if [ "$?" = "0" ]; then
  if [ -f /tmp/Finished-Menu ]; then
  rm /tmp/Finished-Menu
  fi
  exit 1
  else
  ChooseDrive
  exit 0
  fi
  elif [ "$ret" = "252" ]; then
  ChooseDrive
  exit 0
  elif [ "$PartDrive" = "" ]; then
  ChooseDrive
  exit 0
  fi
  PartDrive=$(echo "$PartDrive" | awk -F '|' '{print $1}')
  ## Since unlike the salineos-installer this utility can be run from a non live envoirnment
  ## We need to make sure that the user doesn't try to autopartition the currently used disk.
  RootDir="$(mount | grep -B 0 ' / ')"
  if [ "$AutoPart" = "Auto" ]; then
  if [ "$(echo "$RootDir" | grep "$PartDrive")" != "" ]; then
  $Info --wrap --width=300 --text="You cannot erase the partition this utility is running from, please select another disk or use manual partitioning to select another partition on this disk.\n"
  AutoPartitioning
  fi
  fi
  ## Launch GParted
  if [ "$AutoPart" != "Auto" ]; then
  gparted /dev/$PartDrive
  fi
  if [ "$AutoPart" = "Auto" ]; then
  SwapFile
  exit 0
  else
  SelectRootPart
  exit 0
  fi
  }
  ## Ask the user if they wish to use automatic partitioning.
  AutoPartitioning () {
  $Info --width=400 --wrap --text="You will need at least one partition in order to restore your backup image.\n\nThe installer can erase all data on a hard drive, USB flash drive, or solid state disk of your choice and create this partition for you automatically, or you can manually partition your storage media using GParted.\n\nManual partitioning will allow you to preserve other operating systems and information on your hard disk." --button=$"Partition disk manually:3" --button=$"Erase and use an entire disk:5"
  ret=$?
  if [ "$ret" = "252" ]; then
  AutoPartitioning
  exit 0
  elif [ "$ret" = "5" ]; then
  AutoPart="Auto"
  ChooseDrive
  exit 0
  elif [ "$ret" = "3" ]; then
  AutoPart="Manual"
  ChooseDrive
  exit 0
  fi
  }
  SelectBackupImage () {
  BackupImage=""
  BackupImage=$(yad --file-selection --title="SalineOS-Backup" --height=450 --width=600 --text="\n Select the backup image you wish to restore\n" --button=$"gtk-quit:3" --button=$"gtk-ok:2")
  ret="$?"
  BackupImage=$(echo $BackupImage | awk -F '|' '{print $1}')
  if [ "$ret" = "252" ]; then
  SelectBackupImage
  exit 0
  elif [ "$ret" = "3" ]; then
  $Question --text="Are you sure you want to cancel the resoration?"
  if [ "$?" = "0" ]; then
  if [ -f /tmp/Finished-Menu ]; then
  rm /tmp/Finished-Menu
  fi
  fi
  exit 1
  elif [ "$BackupImage" = "" ]; then
  SelectBackupImage
  exit 0
  elif [ "$(echo "$BackupImage" | grep ".backup")" = "" ]; then
  $Info --button=$"gtk-ok:1" --text="$BackupImage is not a valid backup image"
  SelectBackupImage
  exit 0
  fi
  AutoPartitioning
  exit 0
  }
  MainMenu () {
  Operation=$($SingleMenu --wrap --height=300 --width=400 --text="Please select the operation you wish to perform" "Create a backup image of this SalineOS instance" "Create a backup image of another Linux instance" "Restore a backup image" --button=$"gtk-quit:3" --button=$"gtk-ok:2")
  ret="$?"
  Operation=$(echo "$Operation" | awk -F '|' '{print $1}')
  if [ "$ret" = "3" ]; then
  exit 0
  elif [ "$ret" = "252" ]; then
  MainMenu
  exit 0
  elif [ "$Operation" = "" ]; then
  $Info --text="You must select an operation in order to continue" --button=$"gtk-ok:1"
  MainMenu
  exit 0
  elif [ "$Operation" = "Create a backup image of this SalineOS instance" ]; then
  BackupPart="root"
  StartBackup
  exit 0
  elif [ "$Operation" = "Create a backup image of another Linux instance" ]; then
  SelectBackupPart
  exit 0
  elif [ "$Operation" = "Restore a backup image" ]; then
  SelectBackupImage
  exit 0
  fi
  }
  ## Check for root and cry like a little girl if we don't have it.
  TestRoot="$(whoami)"
  if [ "$TestRoot" != "root" ]; then
  $Info --button=$"gtk-quit:1" --text="SalineOS Backup must be run as root."
  exit 1
  fi
  if [ "$1" = "Restore" ]; then
  BackupImage="$2"
  AutoPartitioning
  else
  MainMenu
  fi
  `

I really liked being able to backup any Debian OS on my machine from the running OS and when that option was removed I missed it and I would be very grateful if you very clever guys could update Anthony's script as it's beyond my skill set. .
Adding an exclude section would be very worth while I think.
golinux

- golinux
- Posts: 663
- Joined: Thu Nov 08, 2012 1:23 am

## Re: Squeeze snapshot

Sat Mar 23, 2013 3:59 pm

Thanks everybody. That's a lot to digest. Let's start with my snapshot_packages and snapshot_exclude.list. Everything in /home is excluded except for configuration files. There should be no media or data files in the snapshot except a few files I stored in a Desktop directory. Note that I do not have Music or Pictures directories so they are not excluded. I kept the bash_history logs because I have a bad memory. I added /opt/* to the exclude list because I have xampp and all my sites working there. I also excluded the /var/log files.
@fsmithred . . . no virtualization working here. I do have an empty external drive that I could copy the files to once I figure out how to mount the iso.
@nadir . . . I would love to do some 'pruning'. But since this setup is critical, I am hesitant to mess with it too much - don't want to break anything. I could start with removing the gnome meta package and nuking hogs like openoffice but again, I don't want to break my working media environment . . .
@ukbrian . . . I absolutely need some sort of exclude options to do any sort of backup. I've just started a huge media project which will come close to filling up my 500gb /home partition. So I don't know how useful your scripts would be.
nadir

- nadir
- Posts: 1160
- Joined: Wed Mar 09, 2011 4:18 am
- Location: here

## Re: Squeeze snapshot

Sat Mar 23, 2013 5:48 pm

Is your username "user" ?
If not, then this is wrong:
# Examples:
- /home/user/Downloads/*
- /home/user/Documents/*
#- /home/*/Music/*
#- /home/user/Pictures/*
- /home/user/Videos/*
-
I see your point about trying not to break anything. As far it is me "apt-get clean" is really super-safe. And cans safe quite some space. If the above is the problem then it should be superfluous anyway.
-
off-the-hook (urgh... off-topic): You were warned to be banned at the thank-you-mr-without-you-a-crap-forum-wouldn't-exist-forum? Ridiculous. Well: i always misunderstand everything ... Probably understood it wrong. Ridiculous anyway ... No one ever thanks me. Without me there would be no interent at all. To start with. Not to speak of the stars in the sky ...
golinux

- golinux
- Posts: 663
- Joined: Thu Nov 08, 2012 1:23 am

## Re: Squeeze snapshot

Sat Mar 23, 2013 7:39 pm

> nadir wrote:Is your username "user" ?
> If not, then this is wrong:
> # Examples:
> - /home/user/Downloads/*
> - /home/user/Documents/*
> #- /home/*/Music/*
> #- /home/user/Pictures/*
> - /home/user/Videos/*

I thought that 'user' was automagically pointed to the user logged in at the time that snapshot was activated. When I took a snap of refracta, I just used the default excludes (which would have included the above) and it came out OK. Hopefully, fsr or dzz will confirm one way or the other. If 'user' does need to be changed, it should be noted in the readme and the script comments.

> nadir wrote:I see your point about trying not to break anything. As far it is me "apt-get clean" is really super-safe. And cans safe quite some space. If the above is the problem then it should be superfluous anyway.

Well, I might give that a try. As far as personal files . . . several times a year, I slog through everything and delete all unnecessaries. But things have built up over the years. But all of that was excluded . . .

> nadir wrote:off-the-hook (urgh... off-topic): You were warned to be banned at the thank-you-mr-without-you-a-crap-forum-wouldn't-exist-forum? Ridiculous. Well: i always misunderstand everything ... Probably understood it wrong. Ridiculous anyway ... No one ever thanks me. Without me there would be no interent at all. To start with. Not to speak of the stars in the sky ...

Not an 'official' warning. Just waving a big stick and some chest thumping. Authoritarian hierarchies don't do well with non-standard anything.
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: Squeeze snapshot

Sat Mar 23, 2013 8:37 pm

Oh boy. Don't know how I missed that, but /home/user/whatever refers to the user whose username is user. If you change the username, those entries won't do anything. It might be possible to replace user with $USER, which is a system variable. Can't recall if I tried that, but I know I tried putting some variable in the excludes file, and it didn't work. Pretty sure it was a variable from the script. If $USER doesn't work... Edit: it won't work right. The user running the script is root.
/home/user can be changed to /home/* if it's ok to exclude whatever from all users' homes. Or replace it with your correct username. I'm gonna have to fix that somehow. And since you had a question about the meaning of /home/* then I guess some explanation is needed right there in the excludes file.
Oh, here you go. When you start snapshot, choose setup and edit the excludes file with geany. Use the find and replace function to put your user name in.
I find it helpful to run graphical disk map for locating big files that I don't need to keep.
'apt-get clean' will remove .deb files from /var/cache/apt/archives, but those files are already excluded. So are a few other apt files.
golinux

- golinux
- Posts: 663
- Joined: Thu Nov 08, 2012 1:23 am

## Re: Squeeze snapshot

Sat Mar 23, 2013 10:04 pm

> Oh boy. Don't know how I missed that, but /home/user/whatever refers to the user whose username is user. If you change the username, those entries won't do anything.

Maybe that's why the iso was so big! Sometimes it takes less experienced eyes to see the obvious. And the fact that I can contribute something related to the actual functioning of a script is kinda cool because I'm pretty clueless about the details of such magic. I'll either use /home/* or delete the second user which is just for once in a while testing. As to locating files . . . the closest thing I can find on squeeze is the disk usage analyzer (Baobab) which isn't all that helpful. What do you suggest? On my own, I just found 18mb of fonts in /home/.fonts/* that I use for graphic work which should probably be excluded. FWIW, I would always edit the config files before initiating a snapshot rather than as part of the process. More trial and error needed but video editing has my attention for the moment. Maybe when I'm cooking dinner or doing my daily exercise. Last snap took a really looong time . . .
dzz

- dzz
- Posts: 647
- Joined: Wed Apr 27, 2011 11:53 am
- Location: Devon, England

## Re: Squeeze snapshot

Sat Mar 23, 2013 10:19 pm

Code:
  `find ~ -type f -size +100M -exec du -h {} \; 2> /dev/null`

Post a reply
Jump to:

Powered by phpBB © phpBB Group.

phpBB Mobile / SEO by Artodia.