Results 1 to 10 of 10

Thread: Script for file backups

  1. #1

    Script for file backups

    One more question for the day...
    I used a slick program to backup my documents and various other files when I was using Win. Now that I am moving over to Linux, I no longer can use this program. I was wondering if anyone here has any recommendations for a script or program that can perform full and incremental backups. I looked online, and there are about 5,000 of them, but I was looking for something that someone had used and could recommend as a good choice. It is very important to me at this point, because I am still learning Linux, and at any given time, my actions could cause the system to grind to a screaming halt, so... Any info would be greatly appreciated.
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    304

    Re: Script for file backups

    You could always write a shell script that uses tar and gzip to create tarball backups of certain directories, then add that to your cron jobs. If you need an example of the shell script or how to do cron jobs I'll post them here. Just let us know

  3. #3

    Re: Script for file backups

    You know what's funny? I never even though of that. I sort of did, but not quite... I am trying to learn some shell scripting, as I have never really used Linux full-time. I am writing a 'program' that runs in a shell, and basically asks for input (such as whether I want to backup an entire folder or just certain files, then takes those files and tar's them), but right at the beginning, I get stuck in a loop and the program does nothing but show the options, over and over, regardless of what options I choose. Needless to say, it is my first script so I didn't expect it to work, but I can't figure out what's wrong with it.
    I like your idea better, as it automates the entire process. I would eventually have to figure out how to incorporate an incremental backup option though. I have had some problems where, while running full backups, some of my files would get corrupted, and I would be backing up the corrupt files. In light of this, I would like to do incremental backups (after the first full backup) that way, I have to physically change a file (which would change the mtime, right?) then only backup the modified files.
    Thanks!
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

  4. #4

    Re: Script for file backups

    After writing such a script, I only need to locate it in /etc/cron.XXX, correct? Can I use a symbolic link in this directory, or do I need to put the script itself in there?
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

  5. #5
    Senior Member
    Join Date
    Nov 2001
    Posts
    304

    Re: Script for file backups

    It's best to put the script in the cron directory if you are using the system folders for cron.daily, weekly, etc...

    It's also best to make sure your script works the way you expect before you make it a cron job. If you need help with your scripting, post what you have and what the problem is here and I'll try to help

    Good luck

  6. #6

    Re: Script for file backups

    This is what I have so far. I know... it is cheesy, ugly, and inefficient, but I just haven't learned enough yet to make a kick a$$ script. I am learning, slowly but surely...
    What I think this should do, correct me if I am wrong, is give me a couple of options on the screen. If I choose 1 or 2, I intend to have it go to another, more in-depth menu, and if I choose Q or q, it should set the flag to '0' which will quit the script (right?). If I choose anything other than those four options, it should simply tell me that I choose an invalid option and to try again.
    Unfortunately, no matter what option I choose, it stays on this main screen and waits to read my choice. No feedback whatsoever, and no exiting.

    #!/bin/bash

    ### MAIN MENU ###
    declare flag=1
    while [ "$flag" -eq "1" ]
    do
    clear
    echo ""
    echo "Ron's Handy Little Archival Script"
    echo ""
    echo "Choose an operation: "
    echo ""
    echo "1. Create Archive from Contents of Entire Folder"
    echo ""
    echo "2. Create Archive of Particular Files"
    echo ""
    echo "Press 'q' to quit..."
    echo ""
    echo "Option: "
    read main
    case $main in
    "1")
    echo "You chose to backup an entire folder."
    ### Run the subprogram to archive an entire folder ###

    ;;
    "2")
    echo "You chose to select various files to archive."
    ### Run the subprogram to archive various files ###

    ;;
    "q") $flag="0"

    ;;
    "Q") $flag="0"

    ;;
    *)
    echo "Please choose an option from the list above."
    esac
    done
    ##### END OF MAIN SCREEN #####

    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

  7. #7
    Senior Member
    Join Date
    Nov 2001
    Posts
    304

    Re: Script for file backups

    Try changing the lines "q") and "Q") to this:

    declare flag=0
    ;;

    if you do that, it should break out. As is, it's trying to execute "1" which isn't a command.

  8. #8

    Re: Script for file backups

    So, "$flag="0"" doesn't set $flag to '0' if "Q" or "q" are selected? Hmmm... You explicitly have to say 'declare'. Interesting.
    Well, I took your suggestion and it now breaks out. You are the MAN!
    I still can't get it to 'echo' if the user selects "1" or "2", or give the error message when you select an invalid option. Oh well, I will read some more of this worthless book and see if I can get somewhere.
    This "Linux Programming for Dummies" book sucks... The funny thing is that this is the second "Dummies" book I have bought, and I had weird problems like this with the last one too. The last one was for LAMP if you are curious... The guy that wrote this book has 29 or so years of UNIX/Linux experience, so I figured it would be a safe bet.
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

  9. #9
    Senior Member
    Join Date
    Nov 2001
    Posts
    304

    Re: Script for file backups

    Hey... if you comment out the "clear" line in your script you'll see that it IS printing what you expect to see... it's just that your while loop is executing right after it's printed and thus... it gets cleared so you don't see it

  10. #10

    Re: Script for file backups

    I am such an idiot... Thanks a lot for pointing that out. I could have been here for weeks, writing letters to the author of this book, calling him all sorts of harsh names...
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

Similar Threads

  1. trouble with Apache File Permissions Script
    By Ed McCorduck in forum Programming
    Replies: 13
    Last Post: 03-13-2010, 11:17 AM
  2. Remote backups using NFS
    By Alize in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 10-26-2009, 05:13 AM
  3. Help with ctreating a script to track changes made to a file
    By sed_addictive in forum Redhat / Fedora
    Replies: 1
    Last Post: 06-10-2009, 01:20 PM
  4. script to check log file....
    By boblucci in forum Programming
    Replies: 3
    Last Post: 11-20-2003, 07:19 AM
  5. backups
    By flandercan in forum Redhat / Fedora
    Replies: 5
    Last Post: 03-31-2003, 03:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •