v 1.4b Sys. Back-Up/Restore & Clean-Up Script - Windows Too!

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Fred

v 1.4b Sys. Back-Up/Restore & Clean-Up Script - Windows Too!

Post by Fred »

Greetings,

For those of you that have been looking for a simple, but easy to use back-up routine, this might be your answer. I had not found a utility that met my needs, that I liked, so I wrote my own little bash script to do what I needed.

I tried to keep it simple so it could be easily understood and modified, but still do the things I wanted.

If you are willing to spend a few min. to configure it to your system, it may be a solution for you too.

I have been using it for a several weeks without issue. Hopefully it doesn't have too many bugs left in it. :-)

Copy the contents of the code box below and paste into an editor.

There are detailed instructions in the file on how to set it up and run it.

EDIT:
At the request of several people I upgraded the script to also selectively back-up and restore your Windows install and/or your Windows Recovery partition and give more options.

Main Features:

1.) Version 1.4b does a better job of initially cleaning up a Linux system.

2.) I fixed some of the menus, and did some code clean-up to make it easier to understand how it works.

3.) The script now has the ability to selectively back-up and/or restore your Windows partition, C:drive, or another Linux install.

4.) The script now has the ability to selectively back-up and/or restore your Windows Recovery partition or another /home partition.

5.) The script now backs-up most of the files in your Linux install and gives you the ability to restore the whole system back to the state it was in at the last back-up if you break it. This can be done with one selection or you can sort through the folders and only restore piece meal if you prefer. It should be about 85% effective at fixing the system.

6.) It isn't recommended, but you can now choose to skip the clean-up portion of the script if you need to for some reason.

7.) You can back-up to or restore from an internal or external drive partition.

8.) The script is not DE specific. It can be used with KDE or Gnome.

9.) The restore portion of the script can be run independently from the back-up schedule selected.

10.) I clarified some of the instructions in the set-up section to make it more complete and easier to understand.

11.) You can now select to have the script make the back-up folders of your choice on your back-up partition for you.

12.) The script uses rsync for fast and efficient back-up / restore of large data stores.

bakclean version 1.4b

Code: Select all

#!/bin/sh

# Written in May of 2008: by - Fred - bakclean version 1.4b

# Any code that I can legally lay claim to in this script
# is released under a dual license. GPL version 2 OR GPL
# version 3. Any derivative code must also be released on
# the same above dual licensing terms.

# I know it is silly to have to do this for a simple little
# script, but these days you just never can tell what might
# happen.

# The clean-up portion of this script removes unused files,
# and other cruft, that collects on your system over time.
# This cruft not only takes up space but can cause other
# system problems. You can choose to not use it below but
# I recommend you leave it active unless you need to keep
# your package download stores intact for later use.

# NOTE!: This script is set up for a single user account.
# Don't attempt to use it if you have multiple user
# accounts. Contact me if you need to be able to deal with
# multiple user accounts. Tell me what your needs are. If
# there is enough interest I will modify it.

# The back-up portion of this script provides for back-up
# and selective restore of your /home data files, your
# /home config files, and most of your Linux system files.
# If you choose to back-up your Linux system files you will
# have the ability to put your system back like it was when
# you last backed it up. This system restore function
# should be about 85% effective in fixing a broken system.

# It will also pick up your data partition files if they
# are mounted in your /home directory and you leave them
# mounted in the script. It also now provides the ability
# to selectively back-up and restore the C:drive of your
# Windows install and it's recovery partition, if you have
# one.

# The C:drive of your Windows install is where all your OS
# system files are stored, as well as your Windows data
# files if you don't have additional drives assigned. This
# too can be deselected.

# The Windows recovery partition makes it possible to
# recover a damaged Windows install. This is usually
# placed on the drive by the computer manufacturer and
# contains all the drivers specific to your hardware. This
# partition can also be deselected.

# This script uses rsync for back-up. This is a very
# efficient method, as it only transfers data that has
# been changed, added or deleted since the last back-up
# was done to maintain a mirror image. This makes
# subsequent back-ups fast and efficient. The same is true
# for the restore process.

# No compression is used so it is relatively easy to go to
# the back-up and retrieve individual files if needed. 

# You must have "dialog" and "deborphan" installed to use
# this script. They will be automatically installed if not
# available on your system.

# I used portions of the below clean-up script. I modified
# and rewrote it to make it safer and more user friendly.
# 
# Script basado en ubucleaner.
# Modificado por Mario Hidalgo | Inacap -Antofagasta
# -Chile | 24 de marzo del 2008

# Cut and paste this script into a text editor and call it
# "bakclean".

# Enter the config data about your system, below.

# Create a hidden folder in your /home folder called
# .ShellScripts :
# mkdir /home/*/.ShellScripts

# Save this script as /home/*/.ShellScripts/bakclean

# Set permissions with:
# chmod 755 /home/*/.ShellScripts/bakclean

# Copy to /usr/bin with:
# sudo cp -a /home/*/.ShellScripts/bakclean /usr/bin

# Execute manually by typing in a terminal: bakclean

# The first time you run this script, it may time-out,
# stop, and require you to re-enter your sudo password.
# This occurs if you have a lot of data to back-up and/or
# a slow computer. It only transfers data that has been
# added or changed since the last run, so it shouldn't
# be a problem after the initial clean-up and back-up
# cycles.

# Depending on your desktop, set this script to start in a
# terminal each time you boot, set it up on a kron tab, or
# use some other scheduling software.

# As an example: In KDE use the auto start module and use
# the start command: konsole -e bakclean

# If you have a partition you are using as a back-up
# partition that is mounted in your /home directory, make
# sure you also have an entry in /etc/fstab for a sdxx
# mount point in /media also. You should have two fstab
# entries for that partition. Example: One /etc/fstab
# entry for mount point /media/sdb2 and one for
# /home/fred/Backup.

# Correct the uncommented lines below for your system.
# Do not change anything after the next # # Begin - Begin
# line.

# Be careful entering your system config data below. Entry
# errors are not allowed. If you do this accurately you
# should have a nice clean-up, back-up and restore system.
# Otherwise you may have a mess.

# Change the folders mounted to other partitions below to
# indicate the data partitions and folders in your /home
# directory that you don't want backed up. You can exclude
# up to 5 folders/partitions from back-up. Always exclude
# the back-up folder if mounted in your /home. If you do
# not have data or back-up partitions mounted in your
# /home this doesn't apply to you. Put "no" in all 5
# positions.

fldr1="Backup"
fldr2="no"
fldr3="no"
fldr4="no"
fldr5="no"

# Set the mounting partitions that correspond to any data
# folders in your /home above, that are being excluded.
# If you do not have data or back-up partitions mounted in
# your /home this doesn't apply to you. Put "no" in all 5
# positions.

prtn1="sdb2"
prtn2="no"
prtn3="no"
prtn4="no"
prtn5="no"

# If you wish to disable the clean-up portion of this script,
# change the "no" entry for skip to "yes".

skip="no"

# If you have a Windows install or another Linux install
# you want to back-up, enter the partition designator, sdxx,
# of your other install below. Enter "no" if you don't have
# another install or you don't wish to back it up.

win="sda7"

# If you are backing up another install above and wish to
# back-up a recovery partition or a /home partition. Enter
# the partition designator below in the form "sdxx" or "no".

winr="sda8"

# Do you want to automatically back-up your another install
# every time the back-up script runs? Enter "yes" below for
# automatic or "no" to be given a choice each time, or if
# you aren't backing up another install.

winrun="yes"

# Do you want to automatically back-up your Windows Recovery
# partition or another /home partition every time the back-up
# script runs? Enter "yes" below for automatic or "no" to be
# given a choice each time, or if you aren't backing up
# Windows Recovery or another /home partition.

winrrun="yes"

# NOTE!: Make sure your Linux system has read/write access
# to your Windows partition and your Windows Recovery
# partition through /media/sdxx for both partitions before
# running the script and attempting to back-up or restore
# Windows or Windows Recovery.

# Set the 3 days of the week you wish to run the backup.
# I use Monday, Thursday, and Saturday. You can set all
# 3 to the same day if you only want to run it once a week.

bak1="Mon"
bak2="Thu"
bak3="Sat"

# If you want it to run anytime the script is called, put
# "anytime" in bak4 below. "stop" will prevent the back-up
# and clean-up portion of this script from running except
# on the 3 days a week specified above. 

bak4="stop"

# The Restore portion of the routine will run whenever
# bakclean is run, regardless of the settings above.

# Create folders on your back-up partition to hold your
# back-up data and files. You can create a master folder
# to hold all of these folders if you want. Create folders
# on your back-up partition sdxx. Change them if you wish.
# Note! -- No spaces allowed in folder names. You must
# back-up and create folders for dataBF and configBF. Enter
# "none" for any folders you choose not to back-up. If you
# are not backing up Windows or Windows recovery, put "none"
# in those two entries also. I called mine:

dataBF="BackUpData"
configBF="BackUpConfig"
usrBF="BackUpUsr"
etcBF="BackUpEtc"
bootBF="BackUpBoot"
binBF="BackUpBin"
sbinBF="BackUpSbin"
libBF="BackUpLib"
devBF="BackUpDev"
varBF="BackUpVar"
winBF="BackDenRoot"; # winBF could be "WindowsXP";
winrBF="BackDenHome"; # winrBF could be "WinRecovery";

# You only have to create folders for dataBF and configBF.
# All the others are optional. If you don't wish to back
# other folders up enter "none" for each.

# Do you have or want a master back-up folder on your back-up
# partition that contains all the back-up folders above? 
# If so, what is it's name? Enter "no" or "folder_name".

bakM="MasterBackUp"

# Would you like the script to make these back-up storage
# folders for you? Enter "yes" or "no" below.

makeBF="yes"

# Put your back-up partition designator in below.

bakP="sdb2"

# NOTE!: Make sure you have allowed enough space in your
# back-up partition to hold all the data you will be
# duplicating there.

# # Begin - Begin --- Don't change anything below this line.
#
# ==========================================
#
# # Begin - Begin --- Start of Restore Utility v 1.4b by Fred

day=$(date +%a)

RESPUESTA=$(dpkg --get-selections | grep -w gnome-terminal | grep -w install)
if [ "$RESPUESTA" != "" ]; then
pid=$(pidof gnome-terminal)
fi

RESPUESTA=$(dpkg --get-selections | grep -w konsole | grep -w install)
if [ "$RESPUESTA" != "" ]; then
pid=$(pidof konsole)
fi

#  ||

RESPUESTA=$(dpkg --get-selections | grep -w dialog | grep -w install)
if [ "$RESPUESTA" = "" ]; then
 sudo aptitude -y install dialog
fi

hm="/home/*"

umt1="$hm/$fldr1"
umt2="$hm/$fldr2"
umt3="$hm/$fldr3"
umt4="$hm/$fldr4"
umt5="$hm/$fldr5"

rmnt1="/dev/$prtn1 $hm/$fldr1"
rmnt2="/dev/$prtn2 $hm/$fldr2"
rmnt3="/dev/$prtn3 $hm/$fldr3"
rmnt4="/dev/$prtn4 $hm/$fldr4"
rmnt5="/dev/$prtn5 $hm/$fldr5"

if test $bakM != "no"; then
bakPP="$bakP/$bakM"
else
bakPP="$bakP"
fi

dataB="/media/$bakPP/$dataBF/$dataBF"
configB="/media/$bakPP/$configBF/$configBF"
usrB="/media/$bakPP/$usrBF/$usrBF"
etcB="/media/$bakPP/$etcBF/$etcBF"
bootB="/media/$bakPP/$bootBF/$bootbBF"
binB="/media/$bakPP/$binBF/$binBF"
sbinB="/media/$bakPP/$sbinBF/$sbinBF"
libB="/media/$bakPP/$libBF/$libBF"
devB="/media/$bakPP/$devBF/$devBF"
varB="/media/$bakPP/$varBF/$varBF"
winB="/media/$bakPP/$winBF/$winBF"
winrB="/media/$bakPP/$winrBF/$winrBF"

dialog --title "Alert! : Do you wish to continue with the Restore utility?" --backtitle "bakclean v 1.4b Script: by - Fred" --yesno "\n           Do you wish to Restore your files?" 8 70
answer2=$?
sleep 1
if test $answer2 -gt 0; then
if test $day != $bak1; then
if test $day != $bak2; then
if test $day != $bak3; then
if test $bak4 != "anytime"; then
kill $pid
exit
fi; fi; fi; fi; fi

answer=1

if test $answer2 -gt 0; then
#
dialog --title "Alert! : Do you wish to continue with the Clean-Up and Back-Up utility?" --backtitle "bakclean v 1.4b Script: by - Fred" --yesno "\n     Do you wish to Clean-Up and optionally Back-Up your files?" 8 70
answer=$?
sleep 1
fi

if test $answer -gt 0; then
if test $answer2 -gt 0; then
kill $pid
exit
fi; fi

if [ $USER != root ]; then
dialog --title "Be patient, Operations may take a while!" --backtitle "Back-Up / Restore & Clean-Up Utility v 1.4b cobbled together by - Fred" --infobox "
   Enter sudo password, if asked, below.  Restart bakclean." 5 75;
sudo -i
exit 0
fi

if test $prtn1 != "no"; then
sudo umount $umt1
fi

if test $prtn2 != "no"; then
sudo umount $umt2
fi

if test $prtn3 != "no"; then
sudo umount $umt3
fi

if test $prtn4 != "no"; then
sudo umount $umt4
fi

if test $prtn5 != "no"; then
sudo umount $umt5
fi

# Select and Restore partitions/folders/files

Rall=1

if test $answer2 -lt 1; then
if test $devBF != "none"; then
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\nDo you wish to Restore all your backed-up Linux System files except your Data files at the same time." 8 80
Rall=$?
sleep 1
#
if test $Rall -lt 1; then
#
sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $configB/ $hm

sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $usrB/ /usr

sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $etcB/ /etc

sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $bootB/ /boot

sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $binB/ /bin

sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $sbinB/ /sbin

sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $libB/ /lib

sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $devB/ /dev

sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $varB/ /var

fi; fi; fi

if test $answer2 -lt 1; then
#
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\nSelect Yes to Restore Data files to your /home.
No for the next choice or to exit." 8 80
Rdata=$?
sleep 1
#
if test $Rdata -lt 1; then
#
sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $dataB/ $hm
fi; fi

if test $answer2 -lt 1; then
if test $Rall -gt 0; then
#
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\nSelect Yes to Restore Config files to your /home. No for the next choice." 8 82
Rconfig=$?
sleep 1
#
if test $Rconfig -lt 1; then
#
sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $configB/ $hm
fi; fi; fi

if test $answer2 -lt 1; then
if test bootBF != "none"; then
if test $Rall -gt 0; then
#
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\nSelect Yes to Restore your /boot folder.
No for the next choice." 8 70
Rboot=$?
sleep 1
#
if test $Rboot -lt 1; then
#
sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $bootB/ /boot
fi; fi; fi; fi

if test $answer2 -lt 1; then
if test etcBF != "none"; then
if test $Rall -gt 0; then
#
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\n       Select Yes to Restore /etc. No for the next choice." 8 70
Retc=$?
sleep 1
#
if test $Retc -lt 1; then
#
sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $etcB/ /etc
fi; fi; fi; fi

if test $answer2 -lt 1; then
if test usrBF != "none"; then
if test $Rall -gt 0; then
#
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\n      Select Yes to Restore /usr. No for your next choice." 8 70
Rusr=$?
sleep 1
#
if test $Rusr -lt 1; then
#
sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $usrB/ /usr
fi; fi; fi; fi

if test $answer2 -lt 1; then
if test binBF != "none"; then
if test $Rall -gt 0; then
#
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\n      Select Yes to Restore /bin. No for your next choice." 8 70
Rbin=$?
sleep 1
#
if test $Rbin -lt 1; then
#
sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $binB/ /bin
fi; fi; fi; fi

if test $answer2 -lt 1; then
if test sbinBF != "none"; then
if test $Rall -gt 0; then
#
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\n      Select Yes to Restore /sbin. No for your next choice." 8 70
Rsbin=$?
sleep 1
#
if test $Rsbin -lt 1; then
#
sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $sbinB/ /sbin
fi; fi; fi; fi

if test $answer2 -lt 1; then
if test libBF != "none"; then
if test $Rall -gt 0; then
#
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\n      Select Yes to Restore /lib. No for your next choice." 8 70
Rlib=$?
sleep 1
#
if test $Rlib -lt 1; then
#
sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $libB/ /lib
fi; fi; fi; fi

if test $answer2 -lt 1; then
if test devBF != "none"; then
if test $Rall -gt 0; then
#
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\n      Select Yes to Restore /dev. No for your next choice." 8 70
Rdev=$?
sleep 1
#
if test $Rdev -lt 1; then
#
sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $devB/ /dev
fi; fi; fi; fi

if test $answer2 -lt 1; then
if test varBF != "none"; then
if test $Rall -gt 0; then
#
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\n      Select Yes to Restore /var. No for your next choice." 8 70
Rvar=$?
sleep 1
#
if test $Rvar -lt 1; then
#
sudo rsync -arE --progress --timeout=120 --include "*" --include "*/**" $varB/ /var
fi; fi; fi; fi

if test $answer2 -lt 1; then
if test $winBF != "none"; then
#
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\nSelect Yes to Restore Windows or another install. No for your next choice." 8 70
Rwin=$?
sleep 1
#
if test $Rwin -lt 1; then
#
sudo rsync -arE --progress --timeout=120 $winB/ /media/$win
fi; fi; fi

if test $answer2 -lt 1; then
if test $winrBF != "none"; then
#
dialog --title "Select files to Restore." --backtitle "Restore" --yesno "\nSelect Yes to Restore Windows Recoveryor another /home partition. No to Exit." 8 70
Rwinr=$?
sleep 1
#
if test $Rwinr -lt 1; then
#
sudo rsync -arE --progress --timeout=120 $winrB/ /media/$winr
fi; fi; fi

if test $prtn1 != "no"; then
sudo mount -a $rmnt1
fi

if test $prtn2 != "no"; then
sudo mount -a $rmnt2
fi

if test $prtn3 != "no"; then
sudo mount -a $rmnt3
fi

if test $prtn4 != "no"; then
sudo mount -a $rmnt4
fi

if test $prtn5 != "no"; then
sudo mount -a $rmnt5
fi

if test $answer2 -lt 1; then
dialog --title "Restore has successfully completed!" --backtitle "Restore" --infobox "
The files you have selected have been successfully Restored!" 5 65; sleep 10
kill $pid
exit
fi

# End of Restore Utility v 1.4b - by Fred
#
# ==========================================
#
# # Begin - Begin --- Start of Clean-Up Utility v 1.4b

if test $skip = "no"; then

OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)

dialog --title "Clean-Up will be done first!" --backtitle "A clean system is more compact and trouble free." --infobox "
   The Clean-Up routine will begin in 5 seconds!" 5 60; sleep 5

RESPUESTA=$(dpkg --get-selections | grep -w deborphan | grep -w install)
if [ "$RESPUESTA" = "" ]; then
 sudo aptitude -y install deborphan
fi

sudo apt-get -y autoremove
aptitude -y autoclean
aptitude -y clean
sudo dpkg --configure -a

sudo aptitude update

sudo aptitude -y purge $OLDCONF
sudo aptitude -y purge $OLDKERNELS

RESPUESTA=$(dpkg --get-selections | grep -w deborphan | grep -w install)
if [ "$RESPUESTA" = "" ]; then
dialog --title "Deborphan failed to load properly." --backtitle "Deborphan" --infobox "
             Restart the bakclean Script." 5 60;
exit 0
else
  for i in `deborphan --guess-all`
  do
      paquetes="$paquetes $i"
  done
  echo $paquetes 
  read
 echo "Please wait. I am working hard..."
  sudo aptitude -y remove --purge $paquetes
fi

sudo apt-get -y autoremove
aptitude -y autoclean
aptitude -y clean

sudo aptitude -y purge $OLDCONF
sudo aptitude -y purge $OLDKERNELS

for a in $(seq 1 2); do
OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
for i in `deborphan --guess-all`
  do
      paquetes="$paquetes $i"
  done
  echo $paquetes 
  read
 echo "Please wait. I am working hard..."
  sudo aptitude -y remove --purge $paquetes

sudo apt-get -y autoremove
aptitude -y autoclean
aptitude -y clean

sudo aptitude -y purge $OLDCONF
sudo aptitude -y purge $OLDKERNELS
done

echo "Please wait. I am working hard..."

cd /usr
find . -type f -name "*~" -exec rm -f {} \;

cd /etc
find . -type f -name "*~" -exec rm -f {} \;

cd /boot
find . -type f -name "*~" -exec rm -f {} \;

cd $hm
find . -type f -name "*~" -exec rm -f {} \;

mkdir Clean-Out

# You can empty the trash of any data folders you have
# mounted in your /home by uncommenting however many
# lines you need below and putting the appropriate folder
# names in place of mine.

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Backup/.Trash-1000

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Backup/.Trash-0

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Documents/.Trash-1000

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Documents/.Trash-0

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Downloads/.Trash-1000

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Downloads/.Trash-0

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Pictures/.Trash-1000

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Pictures/.Trash-0

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Projects/.Trash-1000

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Projects/.Trash-0

sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/.local/share/Trash

sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ /root/.local/share/Trash

sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ /trash

sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ /.trash

rmdir Clean-Out

rm -rf /home/*/.local/share/Trash/*/** &> /dev/null
rm -rf /root/.local/share/Trash/*/** &> /dev/null

sudo apt-get -y autoremove
aptitude -y autoclean
sudo dpkg --configure -a
aptitude -y clean

dialog --title "Alert! : Continue with Back-Up utility?" --backtitle "Clean-Up has completed successfully!" --yesno "\n          Do you wish to continue with the Back-Up process?" 8 70
answer=$?
#
if test $answer -gt 0; then
kill $pid
exit
fi

fi

#
# End of Clean-Up v 1.4b utility, originally by: Modificado
# por Mario Hidalgo | Inacap -Antofagasta -Chile - Modified
# and rewritten by Fred
#
# ===============================================
#
# Start of Back-Up Utility v 1.4b - by Fred
#

if test $skip = "yes"; then
dialog --title "Alert! : Continue with Back-Up utility?" --backtitle "You are now ready to Back-Up your system!" --yesno "\n          Do you wish to continue with the Back-Up process?" 8 70
answer=$?
#
if test $answer -gt 0; then
kill $pid
exit
fi; fi

if test $makeBF = "yes"; then
if test $$bakM != "no"; then
sudo mkdir /media/$bakPP
fi; fi

if test $makeBF = "yes"; then
sudo mkdir /media/$bakPP/$dataBF
sudo mkdir /media/$bakPP/$configBF
	if test $usrBF != "none"; then
	sudo mkdir /media/$bakPP/$usrBF; fi
	if test $etcBF != "none"; then
	sudo mkdir /media/$bakPP/$etcBF; fi
	if test $bootBF != "none"; then
	sudo mkdir /media/$bakPP/$bootBF; fi
	if test $binBF != "none"; then
	sudo mkdir /media/$bakPP/$binBF; fi
	if test $sbinBF != "none"; then
	sudo mkdir /media/$bakPP/$sbinBF; fi
	if test $libBF != "none"; then
	sudo mkdir /media/$bakPP/$libBF; fi
	if test $devBF != "none"; then
	sudo mkdir /media/$bakPP/$devBF; fi
	if test $varBF != "none"; then
	sudo mkdir /media/$bakPP/$varBF; fi
	if test $winBF != "none"; then
	sudo mkdir /media/$bakPP/$winBF; fi
	if test $winrBF != "none"; then
	sudo mkdir /media/$bakPP/$winrBF; fi
fi

answer3=1

if test $win != "no"; then
if test $winrun = "no"; then
#
dialog --title "Select whether to Back-Up your Windows partition." --backtitle "Back-Up System" --yesno "\n Do you wish to back-up your Windows C:drive this time?" 8 70
answer3=$?
sleep 1
fi; fi

if test $winrun = "yes"; then
answer3=0
fi

answer4=1

if test $winr != "no"; then
if test $winrrun = "no"; then
#
dialog --title "Select whether to Back-Up your Windows Recovery partition." --backtitle "Back-Up System" --yesno "\n Do you wish to back-up your Windows Recovery partition this time?" 8 70
answer4=$?
fi; fi

if test $winrrun = "yes"; then
answer4=0
fi

if test $prtn1 != "no"; then
sudo umount $umt1
fi

if test $prtn2 != "no"; then
sudo umount $umt2
fi

if test $prtn3 != "no"; then
sudo umount $umt3
fi

if test $prtn4 != "no"; then
sudo umount $umt4
fi

if test $prtn5 != "no"; then
sudo umount $umt5
fi

# Back-Up Files/Folders

if test etcBF != "none"; then
sudo rsync -arE --progress --delete --timeout=120 --exclude "*~" --include "*" --include "*/**" /etc/ $etcB
fi

if test bootBF != "none"; then
sudo rsync -arE --progress --delete --timeout=120 --exclude "*~" --include "*" --include "*/**" /boot/ $bootB
fi

sudo rsync -arE --progress --delete --timeout=120 --exclude "*~" --exclude ".*" --exclude ".*/**" --include "*" --include "*/**" $hm/ $dataB

sudo rsync -arE --progress --timeout=120 --delete --exclude "*~" --include ".*" --include ".*/**" --exclude "*" $hm/ $configB

if test usrBF != "none"; then
sudo rsync -arE --progress --delete --timeout=120 --exclude "*~" --include "*" --include "*/**" /usr/ $usrB
fi

if test binBF != "none"; then
sudo rsync -arE --progress --delete --timeout=120 --exclude "*~" --include "*" --include "*/**" /bin/ $binB
fi

if test sbinBF != "none"; then
sudo rsync -arE --progress --delete --timeout=120 --exclude "*~" --include "*" --include "*/**" /sbin/ $sbinB
fi

if test libBF != "none"; then
sudo rsync -arE --progress --delete --timeout=120 --exclude "*~" --include "*" --include "*/**" /lib/ $libB
fi

if test devBF != "none"; then
sudo rsync -arE --progress --delete --timeout=120 --exclude "*~" --include "*" --include "*/**" /dev/ $devB
fi

if test varBF != "none"; then
sudo rsync -arE --progress --delete --timeout=120 --exclude "*~" --include "*" --include "*/**" /var/ $varB
fi

if test $answer3 -lt 1; then
if test $win != "no"; then
sudo rsync -arE --progress --delete --timeout=120 /media/$win/ $winB
fi; fi

if test $answer4 -lt 1; then
if test $winr != "no"; then
sudo rsync -arE --progress --delete --timeout=120 /media/$winr/ $winrB
fi; fi

if test $prtn1 != "no"; then
sudo mount -a $rmnt1
fi

if test $prtn2 != "no"; then
sudo mount -a $rmnt2
fi

if test $prtn3 != "no"; then
sudo mount -a $rmnt3
fi

if test $prtn4 != "no"; then
sudo mount -a $rmnt4
fi

if test $prtn5 != "no"; then
sudo mount -a $rmnt5
fi

dialog --title "Back-up has successfully completed!" --backtitle "bakclean v 1.4b by Fred" --infobox "
             That wasn't so bad was it?" 5 60; sleep 10

kill $pid
exit
#
# End
I pulled the clean-up portion of the above script out and made it stand-alone. You can now use the below script to clean-up your system without having to go to the trouble of configuring the back-up script and having to click through the menus.

It turned out that it was a good move because I found a bug that prevented it from emptying the trash cans when very large files and folder trees were in them. I should have known not to use the rm command but I did and it choked on large amounts of data. I fixed it in the 1.4b version.

cleanout version 1.4b

Code: Select all

#!/bin/sh

# Written in May of 2008: by - Fred - cleanout version 1.4b

# Any code that I can legally lay claim to in this script
# is released under a dual license. GPL version 2 OR GPL
# version 3. Any derivative code must also be released on
# the same above dual licensing terms.

# I know it is silly to have to do this for a simple little
# script, but these days you just never can tell what might
# happen.

# Cut and paste this script into a text editor and call it
# "cleanout".

# Create a hidden folder in your /home folder called
# .ShellScripts :
# mkdir /home/*/.ShellScripts

# Save this script as /home/*/.ShellScripts/cleanout

# Set permissions with:
# chmod 755 /home/*/.ShellScripts/cleanout

# Copy to /usr/bin with:
# sudo cp -a /home/*/.ShellScripts/cleanout /usr/bin

# Execute by typing in a terminal: cleanout

# This script uses "Deborphan" and "Dialog." These routines
# will be automaticly downloaded and installed if they are
# not availiable on your system.

# I used portions of the below clean-up script. I modified
# and rewrote it to make it safer and more user friendly.
# 
# Script basado en ubucleaner.
# Modificado por Mario Hidalgo | Inacap -Antofagasta
# -Chile | 24 de marzo del 2008

# # Begin - Begin --- Don't change anything below this line.
#
# ==========================================
#
# # Begin - Begin --- Start of Clean-Out Utility

hm="/home/*"

if [ $USER != root ]; then
dialog --title "Be patient, Operations may take a while!" --backtitle "Clean-Out Utility v 1.4b cobbled together by - Fred" --infobox "
   Enter sudo password, if asked, below.  Restart cleanout." 5 75;
sudo -i
exit 0
fi

RESPUESTA=$(dpkg --get-selections | grep -w gnome-terminal | grep -w install)
if [ "$RESPUESTA" != "" ]; then
pid=$(pidof gnome-terminal)
fi

RESPUESTA=$(dpkg --get-selections | grep -w konsole | grep -w install)
if [ "$RESPUESTA" != "" ]; then
pid=$(pidof konsole)
fi

#  ||

RESPUESTA=$(dpkg --get-selections | grep -w dialog | grep -w install)
if [ "$RESPUESTA" = "" ]; then
 sudo aptitude -y install dialog
fi

OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)

dialog --title "Clean-Out will now begin!" --backtitle "A clean system is more compact and trouble free." --infobox "
   The Clean-Out routine will begin in 5 seconds!" 5 60; sleep 5

RESPUESTA=$(dpkg --get-selections | grep -w deborphan | grep -w install)
if [ "$RESPUESTA" = "" ]; then
 sudo aptitude -y install deborphan
fi

sudo apt-get -y autoremove
aptitude -y autoclean
aptitude -y clean
sudo dpkg --configure -a

sudo aptitude update

sudo aptitude -y purge $OLDCONF
sudo aptitude -y purge $OLDKERNELS

RESPUESTA=$(dpkg --get-selections | grep -w deborphan | grep -w install)
if [ "$RESPUESTA" = "" ]; then
dialog --title "Deborphan failed to load properly." --backtitle "Deborphan" --infobox "
             Restart the cleanout Script." 5 60;
exit 0
else
  for i in `deborphan --guess-all`
  do
      paquetes="$paquetes $i"
  done
  echo $paquetes 
  read
 echo "Please wait. I am working hard..."
  sudo aptitude -y remove --purge $paquetes
fi

sudo apt-get -y autoremove
aptitude -y autoclean
aptitude -y clean

sudo aptitude -y purge $OLDCONF
sudo aptitude -y purge $OLDKERNELS

for a in $(seq 1 3); do
OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
for i in `deborphan --guess-all`
  do
      paquetes="$paquetes $i"
  done
  echo $paquetes 
  read
 echo "Please wait. I am working hard..."
  sudo aptitude -y remove --purge $paquetes

sudo apt-get -y autoremove
aptitude -y autoclean
aptitude -y clean

sudo aptitude -y purge $OLDCONF
sudo aptitude -y purge $OLDKERNELS
done

echo "Please wait. I am working hard..."

cd /usr
find . -type f -name "*~" -exec rm -f {} \;

cd /etc
find . -type f -name "*~" -exec rm -f {} \;

cd /boot
find . -type f -name "*~" -exec rm -f {} \;

cd $hm
find . -type f -name "*~" -exec rm -f {} \;

mkdir Clean-Out

# You can empty the trash of any data folders you have
# mounted in your /home by uncommenting however many
# lines you need below and putting the appropriate folder
# names in place of mine.

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Backup/.Trash-1000

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Backup/.Trash-0

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Documents/.Trash-1000

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Documents/.Trash-0

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Downloads/.Trash-1000

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Downloads/.Trash-0

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Pictures/.Trash-1000

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Pictures/.Trash-0

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Projects/.Trash-1000

# sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/Projects/.Trash-0

sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ $hm/.local/share/Trash

sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ /root/.local/share/Trash

sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ /trash

sudo rsync -r --progress --delete --timeout=120 $hm/Clean-Out/ /.trash

rmdir Clean-Out

rm -rf /home/*/.local/share/Trash/*/** &> /dev/null
rm -rf /root/.local/share/Trash/*/** &> /dev/null

sudo apt-get -y autoremove
aptitude -y autoclean
sudo dpkg --configure -a
aptitude -y clean

dialog --title "Clean-Out has successfully completed!" --backtitle "cleanout v 1.4a by Fred" --infobox "
             That wasn't so bad was it?" 5 60; sleep 10

kill $pid
exit
#
# End
Any suggestions or feed-back you are willing to give me, good or bad, will be greatly appreciated.

Enjoy,

Fred

EDIT: Make sure the partition you are using for backup, whether internal or external, is large enough to hold all the data you will be duplicating there.
Last edited by Fred on Tue Jun 24, 2008 9:39 pm, edited 19 times in total.
Fred

Re: User friendly System Back-Up / Restore & Clean-Up Script

Post by Fred »

micpet,

I don't know what your set up is.

Are you using KDE or Gnome?

Are you trying to use an external drive or an internal drive?

Do you have a partition mounted to a folder in your home, or do you want one mounted there?

Is the partition you want to use formatted as an ext3, NTFS, or fat32?

It would be less confusing for you and easier for me if I knew the answers to the above questions, what you have and what you were trying to accomplish.

Fred


Fred
Fred

Re: User friendly System Back-Up / Restore & Clean-Up Script

Post by Fred »

micpet,

Ok, I understand now. I wasn't clear on whether you had a folder mounted in your /home or if you wanted one. :-)

In fstab, just below the stanza below:

# automatically added, ST9120822A-5LZ8GN7W-part8, /dev/sda8 LABEL=Bak
UUID=46b50ff7-8baa-4b92-a6d9-24ed7e0d0671 /home/mwp/Bak ext3 defaults,noatime

put this stanza in too.

# automatically added, ST9120822A-5LZ8GN7W-part8, /dev/sda8 LABEL=Bak
UUID=46b50ff7-8baa-4b92-a6d9-24ed7e0d0671 /media/sda8 ext3 defaults,noatime

save and close fstab.

Then type in a terminal

cd /media

sudo mkdir sda8

That should do it. Now you have two entries in fstab for the sda8 partition. One for the Bak folder in your /home and one for the sda8 folder you just created in /media.

That should do it. Enjoy.

Fred

EDIT: Reboot for this change to take effect.
Last edited by Fred on Sun Jun 01, 2008 4:57 pm, edited 1 time in total.
Fred

Re: User friendly System Back-Up / Restore & Clean-Up Script

Post by Fred »

For clarification I should add. The folder you have mounted in your /home for backup is a special case. The script must have access to your backup partition in order to be able to backup or restore. But, you can't have that access through your /home folder. The reason is, when you backed up your /home directory you would put yourself in a loop. you would continue copying your backup folder over and over until your partition was filled up and the script would crash.

What the script does is disable access to your backup partition through your /home Bak folder and accesses it through the /media/sda8 folder. That is why you need two entries in your fstab for the same partition.

I hope that helps you understand better.

Fred

PS: What part of NC are you In? I am about 30 miles from Charlotte.
Last edited by Fred on Sun Jun 01, 2008 4:58 pm, edited 1 time in total.
Fred

Re: User friendly System Back-Up / Restore & Clean-Up Script

Post by Fred »

micpet,

I hope it works out well for you. If you have any comments or suggestions I would welcome them. I have been running it on KDE for 2 or 3 weeks without any problem. I tested it on Gnome and it seemed to work ok on it too, but it doesn't have as much test time on Gnome as it does on KDE. The script itself isn't DE specific so I don't anticipate any real problems on Gnome either.

Fred
Fred

Re: User friendly System Back-Up / Restore & Clean-Up Script

Post by Fred »

Ed Wrote,
You know what ?
Just a quick made-up GUI using pyGTK or pyQt and you're done with a nice tool. :wink:
Well, if I were going to do that it would probably be in pyQt or perl, which I have done more of. But I like Qt better and I don't know if there are any good or modern Qt wrappers for perl anymore. I haven't done much programming in the last few years. Most of the stuff I did years ago was in C.

I really don't care to get into a big project, but I might get around to throwing something this simple together, If there seems to be an interest for it. That is if you or Dave don't beat me too it. hint hint :-)

Fred
User avatar
Acid_1
Level 5
Level 5
Posts: 796
Joined: Thu Nov 01, 2007 11:12 pm
Location: Saskatchewan, Canada

Re: User friendly System Back-Up / Restore & Clean-Up Script

Post by Acid_1 »

Awesome Fred. Haha, shows that time machine isn't really as complicated as apple makes it to be :P
Fred

Re: User friendly System Back-Up / Restore & Clean-Up Script

Post by Fred »

I increased the number of passes on the clean-up. It should do a better job of cleaning-up the first time through now. Just keep hitting they "y" for yes when it asks. It shouldn't break anything.

For those of you that have had a bad experience before with "deborphan," I modified it's output to make it safer. It is not quite as aggressive as it would have been otherwise.

I do hope somebody will get some use out of this script and give me some feed back. Good or bad, both are welcome.

Fred
User avatar
Acid_1
Level 5
Level 5
Posts: 796
Joined: Thu Nov 01, 2007 11:12 pm
Location: Saskatchewan, Canada

Re: User friendly System Back-Up / Restore & Clean-Up Script

Post by Acid_1 »

When I buy a external disk, I'll give it a shot (a few weeks from now:P)
idiotkiwi
Level 2
Level 2
Posts: 57
Joined: Fri Feb 02, 2007 2:44 am
Location: Christchurch New Zealand

Re: User friendly System Back-Up / Restore & Clean-Up Script

Post by idiotkiwi »

Fred,

Thanks for the script.

Ran it today, all seems OK and have files located in MasterBackup in external USB drive as anticipated.

I have shutdown failure which came on after some days running Daryna and had hoped that it was because of some broken code. However, apparently not as still exists. I have few real computer skills so your instructions are real good as no problems following them.

Regards
Euan http://www.linuxmint.com/forum/posting. ... 42&t=12988#
Fred

Re: User friendly System Back-Up / Restore & Clean-Up Script

Post by Fred »

idiotkiwi,

Thanks for the feedback. I am glad it seems to be working ok for you.

If I may ask, are you using Gnome or KDE?

Fred
idiotkiwi
Level 2
Level 2
Posts: 57
Joined: Fri Feb 02, 2007 2:44 am
Location: Christchurch New Zealand

Re: User friendly System Back-Up / Restore & Clean-Up Script

Post by idiotkiwi »

Fred,
Using Gnome.

Regards
Euan
Fred

Re: v 1.2 Sys. Back-Up / Restore & Clean-Up Script - Windows Too

Post by Fred »

At the request of several users, I have upgraded the script to version 1.2.

New features:

1.) This version does a better job of initially cleaning up a Linux system.

2.) I fixed some of the menus

3.) The script now has the ability to selectively back-up and/or restore your entire Windows C:drive.

4.) The script now has the ability to selectively back-up and/or restore your Windows Recovery partition.

5.) I clarified some of the instructions in the set-up section to make it more complete and easier to understand.

The new version is in the code box of the initial post.

As always, comments and suggestions are welcome.

Enjoy,

Fred
Fred

Re: v 1.3 Sys. Back-Up / Restore & Clean-Up Script - Windows Too

Post by Fred »

I just posted version 1.3 of bakclean to the original post.

It is more flexible and now gives you more options. If you are running the original version you might want to update to this one.

As always, feed back is welcomed.

Enjoy,

Fred
Fred

Re: v 1.4 Sys. Back-Up / Restore & Clean-Up Script - Windows Too

Post by Fred »

I just posted version 1.4 of the Back-up / Restore and Clean-Up script. You can get it in the original post.

If you are using an earlier version, I would suggest you upgrade to 1.4 and reconfigure. It has a number of added features and fixes.

One feature of note in this version is its ability to restore almost your entire running Linux system back to the condition it was in at the last back-up. A broken system is almost always fixable simply by restoring it back to the last back-up.

You also have the option of backing up two more partitions which could be your Windows install and recovery partition or another Linux install and its /home if on a separate partition. These are mirror images so should be 100% effective in restoring a system back to its condition at last back-up.

Fred
Fred

Re: v 1.4b Sys. Back-Up/Restore & Clean-Up Script - Windows Too!

Post by Fred »

Greetings,

I pulled the clean-up portion of the bakclean script out and made it stand-alone. You can now use the added script to clean-up your system without having to go to the trouble of configuring the back-up script and having to click through the menus.

It turned out that it was a good move because I found a bug that prevented it from emptying the trash cans when very large files and folder trees were in them. I should have known not to use the rm command but I did and it choked on large amounts of data. I fixed it in the 1.4b version.

The bakclean script was updated to fix the clean-up bug also.

You can find the stand-alone cleanout script in the original post at the beginning of the thread.

As usual, any and all feed-back is welcomed and encouraged.

Fred
pjnsmb

Re: v 1.4b Sys. Back-Up/Restore & Clean-Up Script - Windows Too!

Post by pjnsmb »

Fred
After becoming interested in the clean-up script I have followed the instructions and can get as far as the script running and showing "the clean-out routine will begin in 5 seconds" followed by :


Code: Select all

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information       
Initialising package states... Done
Building tag database... Done      
Freed 0B of disk space
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information       
Initialising package states... Done
Building tag database... Done      
Hit http://archive.canonical.com hardy Release.gpg
Ign http://archive.canonical.com hardy/partner Translation-en_GB                
Hit http://security.ubuntu.com hardy-security Release.gpg                       
Ign http://security.ubuntu.com hardy-security/main Translation-en_GB            
Ign http://packages.linuxmint.com elyssa Release.gpg                            
Ign http://packages.linuxmint.com elyssa/main Translation-en_GB                 
Ign http://packages.linuxmint.com elyssa/upstream Translation-en_GB             
Ign http://packages.linuxmint.com elyssa/import Translation-en_GB               
Hit http://archive.ubuntu.com hardy Release.gpg                                 
Hit http://archive.ubuntu.com hardy/main Translation-en_GB                      
Hit http://archive.ubuntu.com hardy/restricted Translation-en_GB                
Hit http://archive.canonical.com hardy Release                                  
Hit http://packages.medibuntu.org hardy Release.gpg                  
Ign http://packages.medibuntu.org hardy/free Translation-en_GB       
Ign http://security.ubuntu.com hardy-security/restricted Translation-en_GB
Ign http://security.ubuntu.com hardy-security/universe Translation-en_GB
Ign http://security.ubuntu.com hardy-security/multiverse Translation-en_GB
Hit http://archive.ubuntu.com hardy/universe Translation-en_GB                  
Hit http://archive.ubuntu.com hardy/multiverse Translation-en_GB                
Hit http://archive.ubuntu.com hardy-updates Release.gpg                         
Ign http://archive.ubuntu.com hardy-updates/main Translation-en_GB              
Ign http://archive.ubuntu.com hardy-updates/restricted Translation-en_GB        
Ign http://archive.ubuntu.com hardy-updates/universe Translation-en_GB          
Ign http://archive.ubuntu.com hardy-updates/multiverse Translation-en_GB        
Get:1 http://packages.linuxmint.com elyssa Release [7841B]                      
Hit http://security.ubuntu.com hardy-security Release                           
Ign http://packages.medibuntu.org hardy/non-free Translation-en_GB              
Hit http://archive.ubuntu.com hardy Release                                     
Hit http://packages.medibuntu.org hardy Release                                 
Hit http://archive.ubuntu.com hardy-updates Release                             
Hit http://archive.canonical.com hardy/partner Packages                         
Hit http://security.ubuntu.com hardy-security/main Packages                     
Hit http://archive.ubuntu.com hardy/main Packages                               
Ign http://packages.linuxmint.com elyssa/main Packages                          
Hit http://security.ubuntu.com hardy-security/restricted Packages    
Hit http://security.ubuntu.com hardy-security/universe Packages      
Hit http://security.ubuntu.com hardy-security/multiverse Packages    
Hit http://packages.medibuntu.org hardy/free Packages                
Hit http://archive.ubuntu.com hardy/restricted Packages              
Hit http://archive.ubuntu.com hardy/universe Packages                
Hit http://archive.ubuntu.com hardy/multiverse Packages              
Hit http://archive.ubuntu.com hardy-updates/main Packages            
Ign http://packages.linuxmint.com elyssa/upstream Packages           
Hit http://packages.medibuntu.org hardy/non-free Packages            
Hit http://archive.ubuntu.com hardy-updates/restricted Packages      
Hit http://archive.ubuntu.com hardy-updates/universe Packages
Hit http://archive.ubuntu.com hardy-updates/multiverse Packages
Ign http://packages.linuxmint.com elyssa/import Packages
Hit http://packages.linuxmint.com elyssa/main Packages
Hit http://packages.linuxmint.com elyssa/upstream Packages
Hit http://packages.linuxmint.com elyssa/import Packages
Fetched 7841B in 0s (8825B/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information       
Initialising package states... Done
Building tag database... Done      
The following packages have been automatically kept back:
  dbus-x11 hal-info linux-image-generic linux-restricted-modules-common 
  linux-restricted-modules-generic xserver-xorg-video-intel 
The following packages have been kept back:
  dbus hal libdbus-1-3 libhal-storage1 libhal1 linux-generic 
  linux-headers-generic util-linux-locales xserver-xorg-core 
  xserver-xorg-video-cirrus 
0 packages upgraded, 0 newly installed, 0 to remove and 16 not upgraded.
Need to get 0B of archives. After unpacking 0B will be used.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information       
Initialising package states... Done
Building tag database... Done      
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information       
Initialising package states... Done
Building tag database... Done      
The following packages have been automatically kept back:
  dbus-x11 hal-info linux-image-generic linux-restricted-modules-common 
  linux-restricted-modules-generic xserver-xorg-video-intel 
The following packages have been kept back:
  dbus hal libdbus-1-3 libhal-storage1 libhal1 linux-generic 
  linux-headers-generic util-linux-locales xserver-xorg-core 
  xserver-xorg-video-cirrus 
The following packages will be REMOVED:
  linux-ubuntu-modules-2.6.22-14-generic{p} 
0 packages upgraded, 0 newly installed, 1 to remove and 16 not upgraded.
Need to get 0B of archives. After unpacking 0B will be used.
Writing extended state information... Done
(Reading database ... 85205 files and directories currently installed.)
Removing linux-ubuntu-modules-2.6.22-14-generic ...
Purging configuration files for linux-ubuntu-modules-2.6.22-14-generic ...
FATAL: Could not open '/boot/System.map-2.6.22-14-generic': No such file or directory
update-initramfs: Generating /boot/initrd.img-2.6.22-14-generic
Cannot find /lib/modules/2.6.22-14-generic
update-initramfs: failed for /boot/initrd.img-2.6.22-14-generic
dpkg: error processing linux-ubuntu-modules-2.6.22-14-generic (--purge):
 subprocess post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-ubuntu-modules-2.6.22-14-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install.  Trying to recover:
Reading package lists... Done             
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initialising package states... Done
Building tag database... Done      
gstreamer0.10-plugins-bad-multiverse libgtkhtml3.16-cil libgtk-vnc-1.0-0 python-gnupginterface python-launchpad-integration libpam-smbpass mozilla-thunderbird openoffice.org-l10n-common bogofilter libdeskbar-tracker libdebconfclient0 python-gtkhtml2 gstreamer0.10-ffmpeg gstreamer0.10-plugins-ugly-multiverse python-gst0.10 liblpint-bonobo0 libpt-1.10.10 gvfs-fuse


the terminal window then just stalls with a black flashing cursor and does not progress past this point .

Any ideas please ?

thanks
Fred

Re: v 1.4b Sys. Back-Up/Restore & Clean-Up Script - Windows Too!

Post by Fred »

pjnsmb,

It appears that it found an inconsistency with your kernel install that it doesn't know how to deal with. Have you had problems with this install?

I would suggest that you run:

sudo aptitude -y install linux-image-generic; sudo aptitude -y reinstall linux-image-generic

Reboot and this should put everything back into order. Then run cleanout again and everything should be ok.

Fred
pjnsmb

Re: v 1.4b Sys. Back-Up/Restore & Clean-Up Script - Windows Too!

Post by pjnsmb »

Fred
thanks for the advice .

I tried your recommendation but it continues to stall.

I am dual booting with Ubuntu but showing the Mint Grub screen, and have consequently modified my menu.lst

It seems it is this set up that is causing the conflict .

Seems I will have to do without your little tool - but thanks anyway

regards
User avatar
67GTA
Level 6
Level 6
Posts: 1301
Joined: Wed Jun 06, 2007 9:49 pm
Location: Kentucky, USA

Re: v 1.4b Sys. Back-Up/Restore & Clean-Up Script - Windows Too!

Post by 67GTA »

I just tried the cleanout script on Elyssa Gnome. I had the same hangup as pjnsmb with 2.6.22-14-generic kernel. I manually created the directories it was complaining about, and it finished. It seems the 2.6.22-14 kernel did not get a clean removal and was only partially still in the file system, and it couldn't finish the script. Should the script display the "Clean-Out has successfully completed!" dialog when it's done? I never saw that. After getting past the kernel error, and running a second time, it just stops.

Code: Select all

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initializing package states... Done
Building tag database... Done      
Freed 0B of disk space
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initializing package states... Done
Building tag database... Done      
Hit http://archive.ubuntu.com hardy Release.gpg                                                                 
Ign http://packages.linuxmint.com elyssa Release.gpg                                                                                        
Hit http://archive.canonical.com hardy Release.gpg                                                                                              
Hit http://security.ubuntu.com hardy-security Release.gpg                                                                                       
Hit http://packages.medibuntu.org hardy Release.gpg                                                                                                          
Ign http://archive.ubuntu.com hardy/main Translation-en_US                                                                                                   
Ign http://packages.linuxmint.com elyssa/main Translation-en_US                                                                                  
Ign http://security.ubuntu.com hardy-security/main Translation-en_US                                                                             
Ign http://archive.canonical.com hardy/partner Translation-en_US                                                                              
Ign http://packages.medibuntu.org hardy/free Translation-en_US                                                                                
Ign http://archive.ubuntu.com hardy/restricted Translation-en_US                                                                                 
Ign http://packages.linuxmint.com elyssa/upstream Translation-en_US                                                                              
Ign http://security.ubuntu.com hardy-security/restricted Translation-en_US                                                                       
Ign http://archive.ubuntu.com hardy/universe Translation-en_US                                                                                
Hit http://archive.canonical.com hardy Release                                                                                                               
Ign http://packages.medibuntu.org hardy/non-free Translation-en_US                                                                                           
Ign http://packages.linuxmint.com elyssa/import Translation-en_US                                                                              
Ign http://archive.ubuntu.com hardy/multiverse Translation-en_US                                                                                 
Hit http://archive.canonical.com hardy/partner Packages                                                                                      
Hit http://packages.medibuntu.org hardy Release                                                                                              
Ign http://security.ubuntu.com hardy-security/universe Translation-en_US                                               
Ign http://packages.linuxmint.com elyssa/backport Translation-en_US                                                     
Hit http://archive.ubuntu.com hardy-updates Release.gpg                                                                    
Ign http://security.ubuntu.com hardy-security/multiverse Translation-en_US                                             
Hit http://packages.medibuntu.org hardy/free Packages                                                                   
Ign http://packages.linuxmint.com elyssa/community Translation-en_US                                                    
Ign http://archive.ubuntu.com hardy-updates/main Translation-en_US                                                                                         
Hit http://security.ubuntu.com hardy-security Release                                                                  
Hit http://packages.medibuntu.org hardy/non-free Packages                                                              
Ign http://packages.linuxmint.com elyssa/romeo Translation-en_US                                  
Ign http://archive.ubuntu.com hardy-updates/restricted Translation-en_US                             
Hit http://security.ubuntu.com hardy-security/main Packages                                          
Ign http://archive.ubuntu.com hardy-updates/universe Translation-en_US
Get:1 http://packages.linuxmint.com elyssa Release [7841B]                                       
Hit http://security.ubuntu.com hardy-security/restricted Packages                                
Ign http://archive.ubuntu.com hardy-updates/multiverse Translation-en_US                          
Ign http://packages.linuxmint.com elyssa/main Packages                                            
Hit http://security.ubuntu.com hardy-security/universe Packages      
Hit http://archive.ubuntu.com hardy-backports Release.gpg                                         
Ign http://packages.linuxmint.com elyssa/upstream Packages                                        
Ign http://packages.linuxmint.com elyssa/import Packages             
Ign http://packages.linuxmint.com elyssa/backport Packages           
Ign http://packages.linuxmint.com elyssa/community Packages          
Hit http://security.ubuntu.com hardy-security/multiverse Packages    
Ign http://packages.linuxmint.com elyssa/romeo Packages
Ign http://archive.ubuntu.com hardy-backports/main Translation-en_US
Hit http://packages.linuxmint.com elyssa/main Packages                                                                                                       
Ign http://archive.ubuntu.com hardy-backports/restricted Translation-en_US                                                                                   
Ign http://archive.ubuntu.com hardy-backports/universe Translation-en_US                                                                                     
Hit http://packages.linuxmint.com elyssa/upstream Packages                                                                                                   
Ign http://archive.ubuntu.com hardy-backports/multiverse Translation-en_US                                                                                   
Hit http://packages.linuxmint.com elyssa/import Packages                                                                                                     
Hit http://archive.ubuntu.com hardy-proposed Release.gpg                                                                                                     
Hit http://packages.linuxmint.com elyssa/backport Packages                                                                                                   
Ign http://archive.ubuntu.com hardy-proposed/main Translation-en_US                                                                                          
Hit http://packages.linuxmint.com elyssa/community Packages                
Ign http://archive.ubuntu.com hardy-proposed/restricted Translation-en_US      
Hit http://packages.linuxmint.com elyssa/romeo Packages                    
Ign http://archive.ubuntu.com hardy-proposed/universe Translation-en_US    
Ign http://archive.ubuntu.com hardy-proposed/multiverse Translation-en_US
Hit http://archive.ubuntu.com hardy Release          
Hit http://archive.ubuntu.com hardy-updates Release                       
Hit http://archive.ubuntu.com hardy-backports Release                     
Hit http://archive.ubuntu.com hardy-proposed Release                      
Hit http://archive.ubuntu.com hardy/main Packages                         
Hit http://archive.ubuntu.com hardy/restricted Packages
Hit http://archive.ubuntu.com hardy/universe Packages
Hit http://archive.ubuntu.com hardy/multiverse Packages
Hit http://archive.ubuntu.com hardy-updates/main Packages
Hit http://archive.ubuntu.com hardy-updates/restricted Packages
Hit http://archive.ubuntu.com hardy-updates/universe Packages
Hit http://archive.ubuntu.com hardy-updates/multiverse Packages
Hit http://archive.ubuntu.com hardy-backports/main Packages
Hit http://archive.ubuntu.com hardy-backports/restricted Packages
Hit http://archive.ubuntu.com hardy-backports/universe Packages
Hit http://archive.ubuntu.com hardy-backports/multiverse Packages
Hit http://archive.ubuntu.com hardy-proposed/main Packages
Hit http://archive.ubuntu.com hardy-proposed/restricted Packages
Hit http://archive.ubuntu.com hardy-proposed/universe Packages
Hit http://archive.ubuntu.com hardy-proposed/multiverse Packages
Fetched 7841B in 1min1s (127B/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initializing package states... Done
Building tag database... Done      
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B of archives. After unpacking 0B will be used.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initializing package states... Done
Building tag database... Done      
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initializing package states... Done
Building tag database... Done      
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B of archives. After unpacking 0B will be used.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initializing package states... Done
Building tag database... Done
If I hit enter it just reruns the above and stops again. Am I clean? :D
"The only thing necessary for the triumph of evil is for good men to do nothing." Edmund Burke
Post Reply

Return to “Tutorials”