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.

# 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".

# 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.

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.

# 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".

# 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.

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.

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.

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

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.

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.

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.