Find the answer to your Linux question:
Results 1 to 3 of 3
Guys, As a linux noob - I spent the last weekend wring a script to automate a backup sequence from the vmware host to an external box of all the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2010
    Posts
    2

    Question Formatting issue - script works though


    Guys,

    As a linux noob - I spent the last weekend wring a script to automate a backup sequence from the vmware host to an external box of all the VM's registered to that host.

    Because for some reason NFS is so sloooooow (don't know why). I have written a script (well a couple really) to backup each vm to the local storage of the vm and then ftp the backup to an external server. FTP is blindingly fast in comparison to NFS

    The script works - so this isn't the usual question of why won't this work.

    Part of the script is a function called backupvm() and is hopefully attached at the end of the message. As its a function containing if....then.....else I like to use indenting to make it more readable. The problem is that if I indent the ftp and its command sequence it won't work any longer (for perfectly reasonable reasons as the command sequence would contain the tabs / spaces added)

    Without using an external command file (which I don't want to do) is there another way of using FTP to put files onto an external server that I can indent properly and make the script look right!!

    Later on I may post both scripts looking for critique - aka how could I do this better

    Regards

    Sean

    -----------------------------------------------------------------------------------------------
    backupvm()
    {
    #Script takes two inputs
    #$1 = VM Name
    #$2 = VM Moref
    #$LOCALSTORE is defined in main body of script and points
    # to the local storage of the VMHost

    cd /scripts

    #Check to see if backup directory exists. Then delete and create or just create
    if [ -d /vmfs/volumes/VMBackup/$1 ]; then
    rm -rf /vmfs/volumes/VMBackup/$1
    mkdir /vmfs/volumes/VMBackup/$1
    else
    mkdir /vmfs/volumes/VMBackup/$1
    fi

    #Run vcbMounter to backup the specific VM to local storage
    vcbMounter -a moref:$2 -r /vmfs/volumes/$LOCALSTORE/$1

    #If the backup directory does not exist then backup has been
    #unsuccessful (vcbMounter is tidy that way). If successful then run ftp
    if [ ! -d /vmfs/volumes/$LOCALSTORE/$1 ]; then
    rm -rf /vmfs/volumes/VMBackup/$1
    else
    cd /vmfs/volumes/$LOCALSTORE/$1
    ftp -iu bucket.olympus.local <<cmd
    user ##### ##########
    cd VMBackup/$1
    mput *
    quit
    cmd
    cd /scripts
    fi

    #Remove the localstore backup directory
    rm -rf /vmfs/volumes/$LOCALSTORE/$1

    }

  2. #2
    Just Joined!
    Join Date
    Jul 2010
    Posts
    53
    should try scp - once you add public key from your machine to account on remote machine then no longer need to supply keyboard login credentials. then is easier to drive from command line and, having setup the ssh keys between machines, gives you more capabilities.

  3. #3
    Just Joined!
    Join Date
    Aug 2010
    Posts
    2
    Quote Originally Posted by chaosless View Post
    should try scp - once you add public key from your machine to account on remote machine then no longer need to supply keyboard login credentials. then is easier to drive from command line and, having setup the ssh keys between machines, gives you more capabilities.
    Unfortunately the host (or even hosts) I have in mind do not support scp out of the box - but I am looking at methods of installing it...

    Also - how do I post code fragments as I notice that the one I posted has the formatting all messed up (ie no indents)



    Sean

Posting Permissions

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