Find the answer to your Linux question:
Results 1 to 3 of 3
Hi guys I be ask to write a bash script at work but could do with help with my first to understand some the syntax. I would be grateful for ...
  1. #1
    Just Joined!
    Join Date
    Jan 2011
    Posts
    19

    Help with my first bash script noob but fast learner

    Hi guys I be ask to write a bash script at work but could do with help with my first to understand some the syntax. I would be grateful for any help



    Copy folder the subs folder within to a folder name temp
    The files within the temp file are then tar
    Then this tar file is check to make sure if this is successful (if successful is carries if not it’s E-mails a error message
    The file is then rsync across to another server for example tom/tom/backup (creditionals for server username tom , password tom)

    The way the backup will work is that the tar will have a naming convection for example 11-jan-11
    The script will then look at the backup folder and if it find anything older than 5 days for example in this case 6-Jan-11 it would delete 4-jan-11, 5-jan-11 etc.

    It will then E-mail reporting a success

    Thanks
    Tom

  2. #2
    Just Joined!
    Join Date
    Jan 2011
    Posts
    19
    This what I done so far just need point the right direction please

    #! /bin/bash
    cd /home/ops/Desktop/dir1
    # Navigate to the correct directory

    cp -p * /home/ops/Desktop/temp
    # copy the data within dir1 into a new folder name temp. The -p preserves the modification date and time etc

    cd /home/ops/Desktop/temp

    tar czvf test="$(date +%d-%b-%y".tgz /home/ops/Desktop/temp


    regarding the last line here could some how I can save the tar with the date as the naming convetion please as you probably can tell mine won't work

  3. #3
    Just Joined!
    Join Date
    Jan 2011
    Posts
    19
    Quote Originally Posted by thomas130 View Post
    This what I done so far just need point the right direction please

    #! /bin/bash
    cd /home/ops/Desktop/dir1
    # Navigate to the correct directory

    cp -p * /home/ops/Desktop/temp
    # copy the data within dir1 into a new folder name temp. The -p preserves the modification date and time etc

    cd /home/ops/Desktop/temp

    tar czvf test="$(date +%d-%b-%y".tgz /home/ops/Desktop/temp


    regarding the last line here could some how I can save the tar with the date as the naming convetion please as you probably can tell mine won't work

    Dont worry I got that bit to work

Posting Permissions

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