directory backup to cd
Results 1 to 9 of 9

Thread: directory backup to cd

  1. #1
    Join Date
    Mar 2001
    Location
    Adelaide, SA, Australia
    Posts
    823

    directory backup to cd

    Thanks to the helpful people at virtualdr I was able to fix my samba problem, but now one more problem exists.
    The linux server I setup is going to have a CD-Writer installed into it for backing up once a week.
    I know how to enable scsi emulation on the burner but could someone help me with creating a shell script and automating it with cron. What I would like to be able to setup is for the machine to burn the contents of a directory (for example one called backup) onto a CD at 11:30pm every Friday, then delete the backup file after it has finished and for the CD to be ejected.

    I know to backup to cd I enter to following commands at the shell prompt.

    mkisofs -o /var/tmp/backup.cd /backup
    cdrecord -v speed=24 dev=0.0.0 -data /var/tmp/backup.cd

    Thank you in advance for any people who help me, as I would also like to do this to my server as well.
    Yuri.

    EDIT: Forgot to mention that the distro is Redhat 7.2
    Last edited by Yuri; July 2nd, 2002 at 05:51 AM.
    In a world without fences, who needs GATES?

  2. #2
    Join Date
    Mar 2001
    Location
    Adelaide, SA, Australia
    Posts
    823
    *bump*
    In a world without fences, who needs GATES?

  3. #3
    Join Date
    Mar 2001
    Location
    Adelaide, SA, Australia
    Posts
    823
    Ok I have been reading various how-to files for a while and this is what I have come up with could someone please have a look at it and let me know if it would work, also how to make the CD eject after it has finished.
    Yuri.
    Attached Files Attached Files
    In a world without fences, who needs GATES?

  4. #4
    Join Date
    Sep 2001
    Location
    Ireland
    Posts
    990
    Script
    Your script is fine Yuri, but change the first line to:

    #!/bin/bash

    as your using the bash shell, if your not just leave it as sh.

    The command to eject is simply eject, but i tried it on a suse 6.2 box and it didnt work, it did work on a suse 7.2 box though, so you should check it before making it part of your script.

    In the rm command add a -f (force) in case any files don't want to be removed, this could make your script hang, and add exit 0 to the end of your script to end it tidily.

    Make sure the script is saved in a dir that is in your $PATH eg /usr/bin, to check your path type echo $PATH.

    To make it exe type chmod 755 backup.sh if your script is saved in a dir with your path typing backup.sh will execute it.

    Cron
    Ok so you want to make the script run at 2330 every friday, to do this do the following.
    type: crontab -e
    this will put you into crontab's edit mode, press i or insert, now add the lines:

    # Backup script to be run each friday @ 11.30pm
    30 23 * * 5 root /usr/bin/backup.sh

    Explanation: 30 = 30 mins past the hour, 23 = 11 o'clock, 5 = 5th day (friday)

    To save do the following (in red):
    press escape
    now type a : followed by wq (write, quit) and press return, to exit without saving do q!

    If this does not work check man crontab and man 5 crontab.

    As is the case with any script no matter now simple TEST it to you are 100% on it, espically in your case where there is an rm command running automatically.

    I have attached a simple document on shell scripting to help you out, you will easily learn the basics from it, go to the Linux Documentation Project and look for the Advanced Bash Scripting how to when you feel you need to learn more about scripting.

    RB
    Attached Files Attached Files
    Last edited by rami3; July 5th, 2002 at 05:39 AM.

  5. #5
    Join Date
    Mar 2001
    Location
    Adelaide, SA, Australia
    Posts
    823
    Rami3 thank you very much for your help I will make the changes and put the script file in to cron. And let you know how I go.
    VirtualDR would not be the same without you.
    Thanks.
    Yuri.
    In a world without fences, who needs GATES?

  6. #6
    Join Date
    Mar 2001
    Location
    Adelaide, SA, Australia
    Posts
    823
    The script works really well and does exactly what I need it to do, the only problem is that every file/folder is only 8 characters. Is there any way to make it so that the folders and files can be longer up to 255 characters?
    Yuri.
    In a world without fences, who needs GATES?

  7. #7
    Join Date
    Mar 2001
    Location
    Adelaide, SA, Australia
    Posts
    823
    *bump* anyone know how to get around the 8 character limit?
    In a world without fences, who needs GATES?

  8. #8
    Join Date
    Mar 2000
    Location
    Elyria, Ohio - USA
    Posts
    2,075
    From:

    http://www.nber.org/cdrecord.html

    There are a lot of options described in the man page. If you keep your filenames to 8.3 lower case, you won't need to be bothered with most of them. The "-J" option (for Joliet) will allow longer Windows style filenames, but if you actually use longer or case sensitive names your file names will look funny or not work in a minimal ISO9660 system.
    That's about the best I could come up with. Hope it helps. -mk
    If it ain't broke,
    Fix it till it is.

  9. #9
    Join Date
    Mar 2001
    Location
    Adelaide, SA, Australia
    Posts
    823
    Thanks for that Mike worked like a charm.
    Yuri.
    In a world without fences, who needs GATES?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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