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

Write tutorials and howtos in here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please. Before you post please read this

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

Postby Fred on Sat May 31, 2008 10:46 am

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.
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Linux Mint is funded by ads and donations.
 

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

Postby ed@Mint on Sat May 31, 2008 12:03 pm

Impressive work, Fred 8)
This might get very useful to a lot of people.

The numerous comments and documentation are a very valuable addition too.
I'll give it a more detailed look when i have time.

You know what ?
Just a quick made-up GUI using pyGTK or pyQt and you're done with a nice tool. :wink:

Thanks for your time.
In libro veritas

Now switched to : ArchLinux

New users, read the Linux Mint User Guide | Problem ? See the Wiki first | Check out the Software Portal | Join the IRC channel : #linuxmint @ irc.spotchat.org
User avatar
ed@Mint
Level 5
Level 5
 
Posts: 565
Joined: Sun Mar 09, 2008 6:03 pm
Location: Liege, Belgium

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

Postby micpet on Sat May 31, 2008 6:54 pm

@Fred-

How do I create the sdxx mount point in /media and the /etc/fstab file?
User avatar
micpet
Level 1
Level 1
 
Posts: 47
Joined: Sat Nov 03, 2007 6:10 am
Location: North Carolina, USA

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

Postby Fred on Sun Jun 01, 2008 4:17 am

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
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

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

Postby micpet on Sun Jun 01, 2008 6:54 am

# 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 /media/sda6
# and one for /home/fred/Backup.


My set up is a laptop. I also use an 7 year old desktop for playing with distros. It is presently running sidux, kde lite. The lap runs Mint mostly.

I have a backup partition mounted in my home folder as well as a music and video data partitions. Also mounted in home folder. By the way, thanks, couldn't have learned to do that and change the uuid's in fstab without going through all the data you and others have put here in the forums.

As you know these partitions appear as mounted volumes like any usb device. But this is in system:/media, I was on the old computer at the time, looking at things, while reading through the script. So what are referring too with the two entries: one is using the partition label and the other is using partition number. Are you saying that we should make sure that both entries appear for each partition uuid in /etc/fstab? If so mine already do. I do not use shorthand as some may do when making entries in the fstab. Or, are your implying a second entry of the partition information in another file of some kind. that is basically what I am trying to understand.

At any rate, I use only linux. All my partitions are formatted to ext3. I guess that about covers it. If you need more info, let me know. Thanks for the help.

Edit: almost forgot -- the backup data partition has root privleges only. The others are owner.
User avatar
micpet
Level 1
Level 1
 
Posts: 47
Joined: Sat Nov 03, 2007 6:10 am
Location: North Carolina, USA

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

Postby micpet on Sun Jun 01, 2008 7:02 am

#
# <filesystem> <mountpoint> <type> <options> <dump> <pass>

# automatically added, ST9120822A-5LZ8GN7W-part2, /dev/sda2
UUID=d744a8f9-a311-4e3f-b65e-388d4c5a51c6 / ext3 defaults,noatime,errors=remount-ro 0 1

# automatically added, ST9120822A-5LZ8GN7W-part5, /dev/sda5, LABEL=home
UUID=bdac8234-fdbe-41fc-8414-82b87beee53a /home ext3 defaults,noatime 0 2

# automatically added, ST9120822A-5LZ8GN7W-part6, /dev/sda6 LABEL=Music
UUID=3d8987d2-b166-46f2-9e47-6f96d2fbe9df /home/mwp/Music ext3 defaults,noatime

# automatically added, ST9120822A-5LZ8GN7W-part7, /dev/sda7 LABEL=Videos
UUID=abf88f5a-a57c-4f1a-a0fa-642469b51bf6 /home/mwp/Videos ext3 defaults,noatime

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

# automatically added, ST9120822A-5LZ8GN7W-part1, /dev/sda1
UUID=191f7da5-baa6-480c-b5fb-a600627bba23 none swap sw 0 0

# automatically added, QSI_DVD+-RW_SDW-085
/dev/cdrom /media/cdrom udf,iso9660 user,noauto 0 0

# temporary filesystem in virtual memory


Just in case you want a visual of /etc/fstab.
User avatar
micpet
Level 1
Level 1
 
Posts: 47
Joined: Sat Nov 03, 2007 6:10 am
Location: North Carolina, USA

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

Postby Fred on Sun Jun 01, 2008 10:53 am

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.
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

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

Postby Fred on Sun Jun 01, 2008 2:14 pm

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.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

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

Postby micpet on Sun Jun 01, 2008 3:14 pm

Thanks Fred. I understand what's going on now.

Location is Holly Springs. Not far from Raleigh, Cary, and RTP.

I'll let you know how the script runs. Thanks for the help.
User avatar
micpet
Level 1
Level 1
 
Posts: 47
Joined: Sat Nov 03, 2007 6:10 am
Location: North Carolina, USA

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

Postby Fred on Mon Jun 02, 2008 12:38 am

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
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

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

Postby Fred on Mon Jun 02, 2008 3:32 pm

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
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

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

Postby Acid_1 on Wed Jun 04, 2008 2:40 am

Awesome Fred. Haha, shows that time machine isn't really as complicated as apple makes it to be :P
Website: Forkwhilefork
User avatar
Acid_1
Level 5
Level 5
 
Posts: 817
Joined: Thu Nov 01, 2007 11:12 pm
Location: Saskatchewan, Canada

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

Postby Fred on Fri Jun 06, 2008 7:28 am

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
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

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

Postby Acid_1 on Sun Jun 08, 2008 2:49 am

When I buy a external disk, I'll give it a shot (a few weeks from now:P)
User avatar
Acid_1
Level 5
Level 5
 
Posts: 817
Joined: Thu Nov 01, 2007 11:12 pm
Location: Saskatchewan, Canada

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

Postby idiotkiwi on Sun Jun 08, 2008 4:09 am

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 posting.php?mode=reply&f=42&t=12988#
idiotkiwi
Level 2
Level 2
 
Posts: 58
Joined: Fri Feb 02, 2007 2:44 am
Location: Christchurch New Zealand

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

Postby Fred on Sun Jun 08, 2008 9:28 pm

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
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

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

Postby idiotkiwi on Mon Jun 09, 2008 2:55 am

Fred,
Using Gnome.

Regards
Euan
idiotkiwi
Level 2
Level 2
 
Posts: 58
Joined: Fri Feb 02, 2007 2:44 am
Location: Christchurch New Zealand

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

Postby Fred on Tue Jun 10, 2008 4:24 am

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
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

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

Postby Fred on Thu Jun 12, 2008 11:53 pm

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
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

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

Postby Fred on Mon Jun 16, 2008 6:02 pm

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
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Linux Mint is funded by ads and donations.
 
Next

Return to Tutorials / Howtos

Who is online

Users browsing this forum: rsadix and 14 guests