Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: How Do I Write A Batch File in Linux?

  1. #1
    Join Date
    Feb 2009
    Location
    Georgia
    Beans
    87
    Distro
    Ubuntu 10.04 Lucid Lynx

    How Do I Write A Batch File in Linux?

    I do hope that this is the appropriate forum for this question.

    I have a few batch files I used in Microsoft Windows that helped me to do ordinary task such as disk checks / defrags and other maintenance issues but one of the big things was my back up batch files. I really like the fact that I could click and Icon and all my important files were backed up to a central location then zipped up for storing on an external drive or optical disc. I would appreciate any help in this matter.

    Currently Running:
    Compaq V5000
    250 gig EIDE internal Hard drive
    320 Gig Portable Hard drive
    150 Gig External Hard drive
    2.O Gig of Ram
    Windows XP Media Center sp3 with Ubuntu 10.04 LTS

  2. #2
    Join Date
    Feb 2007
    Location
    West Hills CA
    Beans
    10,044
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How Do I Write A Batch File in Linux?

    In the upper right corner is a search box. Try searching:

    rsync backup scripts

    You will get a lot of hits including:

    http://ubuntuforums.org/showthread.p...backup+scripts

    For more specific help, post one of your backup batch files and maybe someone will transcribe it for you as a backup script.

    To create an icon the the desktop, simply right-click and "Create Launcher". Fill in the details and point to the backup script you just wrote.

    The basic steps:

    nano my_personal_backup_script.sh

    (Edit the script and save it, Control-O, Control-X)

    Make it executable:

    sudo chmod +x my_personal_backup_script.sh

    Run it:

    ./my_personal_backup_script.sh

    Run it automatically by placing it in a crontab, either systemwide or personal.

    Make a launcher icon on the desktop.
    -------------------------------------
    Oooh Shiny: PopularPages

    Unumquodque potest reparantur. Patientia sit virtus.

  3. #3
    Join Date
    Feb 2009
    Location
    Georgia
    Beans
    87
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How Do I Write A Batch File in Linux?

    tgalati4 thanks for the info. I did a search however I used Linux Batch and I got nothing of relevance I didn't think to search for backup scripts.

    here is one of the backups I used to use for windows.

    @echo Off

    @echo Author: Argedion

    @REM Purpose of File: To Back up Setting Files to ReWritable CD

    @REM File Name: CDSav.bat

    @REM Origination Date: 1:57 PM 4/16/2003

    @echo.

    cls

    @echo.

    @echo.
    @copy C:\windows\system32\drivers\etc\hosts D:\mydocu~1\mysett~1\hostsf~1 /y > NUL

    @copy C:\docume~1\argedion\locals~1\applic~1\micros~1\ou tlook\*.* D:\MyDocu~1\Micros~1\outlook /y > NUL

    @echo Files Ready for Copying to Compact Disk Please Place ReWritable CD into Burner

    @xcopy D:\mydocu~1\mysett~1\*.* f:\Stored\ /s /y > NUL

    @xcopy D:\Projects\VB\*.* f:\MyBasic\ /s /y > NUL

    This was used for sending stuff to the cd burner. I no longer use cd's with thumbdrives being so much easier to store and carry around.

    I mainly wish to just have a simple script to backup the /home folder to one of my thumb drives. Mainly I just want to save my files and not a bunch of programming files that are only good for now and not necessarily later I also wish to compress everything with 7zip before sending it to the thumb drive.

  4. #4
    Join Date
    May 2007
    Location
    East Yorkshire, England
    Beans
    Hidden!

    Re: How Do I Write A Batch File in Linux?

    "Batch" files in GNU/Linux are shell scripts; if you can use a terminal you can write scripts. I would link you to my backup script, but ubuntuforums is censoring the URL for some reason: https://gith*******/Barrucadu/home/b...ter/bin/backup
    Website | Blog | The Arch Hurd Project

    If you want to ask about something I posted, send a PM, as I don't watch many threads

  5. #5
    Join Date
    Feb 2009
    Location
    Georgia
    Beans
    87
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How Do I Write A Batch File in Linux?

    Barracuda I was able to find this one

    home / bin / backup

    It almost looked like a complex program I would need some help setting up something of this nature considering the basic's of my batch file. I'm an old man willing to learn though all I need is a Good Teacher with Great Patience

  6. #6
    Join Date
    Sep 2009
    Location
    Canada, Montreal QC
    Beans
    1,809
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: How Do I Write A Batch File in Linux?

    Linux Bash scripts is the equivalent of WInodows batch files.
    I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
    Freedom is measured in Stallmans.
    Projects: gEcrit

  7. #7
    Join Date
    Nov 2009
    Location
    The Netherlands
    Beans
    239
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How Do I Write A Batch File in Linux?

    a simple script to backup your home folder to a thumb drive would be:
    Code:
    #!/bin/bash
    today=`date +%Y%m%d`
    tar cPf - /home | 7za a -si /media/MY_THUMB/backup_$today.tar.7z
    this makes a tar file containing your home directory, passes it to 7zip and stores it as backup_20101114.tar.7z on a drive called MY_THUMB if you run it today

    to restore your files back run
    Code:
    $7za x -so /media/MY_THUMB/backup_20101114.tar.7z | tar x
    from your / folder

  8. #8
    Join Date
    Feb 2009
    Location
    Georgia
    Beans
    87
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How Do I Write A Batch File in Linux?

    ok thanks for the info.

    I see I am going to have to learn bash besides the link to programming is there any other places to learn the basics

  9. #9
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: How Do I Write A Batch File in Linux?

    My first bash file was a list of history where I had run several commands to test that they did what I wanted and copied them into a script.

    The tar will combine & compress you files for smaller space, but some like to be able to see all the files and easily recover just one. rsync then is a command for that.

    Originally Posted by MountainX View Post #20 also other backup apps
    http://ubuntuforums.org/showthread.p...ghlight=backup

    One of many places to learn about bash:
    http://mywiki.wooledge.org/BashGuide
    Whiptail is a program that allows shell scripts to display dialog boxes
    http://en.wikibooks.org/wiki/Bash_Sh...Using_whiptail
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

  10. #10
    Join Date
    Feb 2009
    Location
    Georgia
    Beans
    87
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How Do I Write A Batch File in Linux?

    Thanks oldfred

    I really just want to be able to write some simple bash files to do the task of backing up and other task I may find usefull to do as I continue to learn linux. I never bothered with backup programs for the other OS because most of them came at a cost and I found it more comforting to write a batch file to do the job. While I continue to use batchfiles in that other OS since its a pretty stupid system and cant read my ext4 file system it makes it hard for me to use a batch in that system to backup my linux system. One thing this has taught me is even though I've been messing with linux for a few years I havent yet really learned anything about it. I guess my first approach needs to be understanding what commands are available and how to use them like I did the other OS. I'm to used to stuff like dir /w and xcopy this that /s . As much as I would like to writing bash files I really need to understand the commands that are available and how to use those first. I've just started reading an intro to linux figuring that was probably the best place to start. I have allowed that other system to make me a GUI junkie and a Command line Flunkie. Now I have to learn real computing. Anyone wanting to help an old man learn new tricks can email me *L* The one thing I do know is that I really love the Linux community and the amazing willingness to help poor wanna be's like me
    Currently A Command Line Flunkie an a GUI Junkie
    I believe in Jesus Christ

Page 1 of 2 12 LastLast

Tags for this Thread

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
  •