Page 4 of 4 FirstFirst ... 234
Results 31 to 37 of 37

Thread: couple rsync with tar.bzip2

  1. #31

    Default Re: couple rsync with tar.bzip2

    It looks like that Yast PArtitioner can assign a label to the disk without reformating it.

    ImageShack® - Online Photo and Video Hosting

    What I am not sure which is the right option for the labeling

    Mound in /etc/fstab by volume label, uuid, e.t.c what should I have there?

    So once I assign a label always the same disk would be mounted right?

    Alex

  2. #32
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: couple rsync with tar.bzip2

    On 2013-03-06 12:46, alaios wrote:
    >
    > It looks like that Yast PArtitioner can assign a label to the disk
    > without reformating it.
    >
    > 'ImageShack® - Online Photo and Video Hosting'
    > (http://imageshack.us/photo/my-images/96/details1w.jpg/)


    Maybe.

    As I personally would not do it that way, I don't really know if it is
    possible or not :-)

    > What I am not sure which is the right option for the labeling


    :-?

    Name is arbitrary, anything you like. "ExtBackup_1", for instance.


    > Mound in /etc/fstab by volume label, uuid, e.t.c what should I have
    > there?


    :-?

    > So once I assign a label always the same disk would be mounted right?


    Once you assign a label and mount by label, it does not matter how the
    disk is connected (usb, sata, esata, etc), the name is the name. It does
    not matter when you plug it in. It is safe and also easy for your to
    recognize what it is.

    Of course, don't have two partitions with the same name...


    --
    Cheers / Saludos,

    Carlos E. R.
    (from 11.4, with Evergreen, x86_64 "Celadon" (Minas Tirith))

  3. #33

    Default Re: couple rsync with tar.bzip2

    Hi I have start working on the script, so more failure stories will be appearing soon.

    Two things that are high on my list

    1. what is the mailutils package for opensuse. My mail command line does not send emails
    Code:
     mailq -AC postqueue: fatal: Queue report unavailable - mail system is down user@host:~> mailq -Lq postqueue: fatal: Queue report unavailable - mail system is down
    2. Should the backup scripts run with root permissions? If the paths are fully written (so nothing relative) I do not see nothing wrong from copying file system directories (local and remote) to external hard disk (directly connected to the system)

    Cheers
    Alex

  4. #34

    Default Re: couple rsync with tar.bzip2

    Hi I came back with my decent try. Please have a look. I have written the code (at least I tried to be readable by any user.) There you will find points need attention and your comments.

    Please have a look and comment where is needed

    Code:
    #!/bin/bash
    
    # The scripts should always start with the external devices unmounte.
    # 1. First checks that the device is not mounted (that should be always)
    # 2. Mounts the device
    # 3. Copy the files
    # 4. Unmounts the device
    # 5. Send emails at the moment a failure appears or at the end when everything was succesful
    
    
    SCRIPTNAME="BACKUPOFDATA.SH"
    MOUNTPOINT=/mnt/BckpMeasurements
    MAILADDRESS="hidden@hidden.com"
    
    # 1.
    MOUNT=`mount | grep $MOUNTPOINT`
    if ! test -n "$MOUNT" ; then
            #2.
            mount $MOUNTPOINT 
            # In case the above did not work. I need to send email with message and stop immediately. How I check that the mount was done?
    else
            echo "Device already mounted! Why? Check if something wrong happened with the backup scripts" | mail -r \
                                    $MAILADDRESS -s "Backup Scripts Failed" $MAILADDRESS
            exit
    
    fi
    
    # Do the Copy of The Files
    
    # 3.
    # rsync command goes here
    # if rsync failes send an email to me too
    
    # How to check that rsync returned succesfully
    # End of Copy of the files
    
    
    # 4.
    # Unmount the Device
    umount $MOUNTPOINT
    MOUNT=`mount | grep $MOUNTPOINT`
    if  test -n "$MOUNT" ; then
            echo "Device Failed to be unmounted! Why? Check if something wrong happened with the backup scripts" | mail -r \
                                    $MAILADDRESS -s "Backup Scripts Failed" $MAILADDRESS
            exit
    fi
    
    
    # I want to send me also an email with backup sucessful
    # That should be when rsync returned succesfully and the unmount was too.
    
    # 5.
    echo "Script Name: Data and Time. Rsync finished successfully. Device was also unmounted Successfully. Send a kiss to robin_lista" | mail -r \
                                    $MAILADDRESS -s "Backup Scripts Finished at" $MAILADDRESS

  5. #35
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: couple rsync with tar.bzip2

    On 2013-03-07 11:46, alaios wrote:

    > 1. what is the mailutils package for opensuse. My mail command line
    > does not send emails



    Try 'mail', not 'mailq'. Different things. The current package name is
    'mailx', because it is an improved version of the traditional unix
    'mail' command. Should be installed by default.

    You probably also need service 'postfix' running and at least minimally
    configured. This is done via the yast mail module. Just accept the
    default, don't try the extended or extra or whatever they call that
    mode, it is complex.

    (ignore the questions about your mail account: that would simply
    configure fetchmail to get your email for you. Of course, do it if you
    want it that way: I do).

    If you want help on how to use CLI 'mail' to send emails from scripts,
    please start a new thread with that subject, it is too different subject
    from doing backups and it has its own complexities.


    > 2. Should the backup scripts run with root permissions? If the paths
    > are fully written (so nothing relative) I do not see nothing wrong from
    > copying file system directories (local and remote) to external hard disk
    > (directly connected to the system)


    Yes, backup scripts normally have to run as root, or they will not be
    able to save anything but your home.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 11.4, with Evergreen, x86_64 "Celadon" (Minas Tirith))

  6. #36
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: couple rsync with tar.bzip2

    On 2013-03-07 12:46, alaios wrote:
    >
    > Hi I came back with my decent try. Please have a look. I have written
    > the code (at least I tried to be readable by any user.) There you will
    > find points need attention and your comments.
    >
    > Please have a look and comment where is needed


    Do it this way:

    1) Mount the external device.

    2) Then check if it is not mounted, and in that case, bail out, send
    email, whatever. This step is what the snippet of code I posted
    previously does.

    3) Do the backup.

    4) umount the device.

    You can write messages on each step of the process to a file, and at the
    end email that text file. The messages that rsync prints to the screen
    can go instead, or also, to that file, so by reading the email you know
    if rsync succeeded or not.

    Hint: read the rsync manual page, seek for 'exit values'. You can use
    that in scripts.


    Start with a simple script and add to it, by pieces.


    If sending emails to an address in Internet is needed (ie, not on the
    local network), then please start a new thread about that.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 11.4, with Evergreen, x86_64 "Celadon" (Minas Tirith))

  7. #37

    Default Re: couple rsync with tar.bzip2

    Quote Originally Posted by robin_listas View Post
    On 2013-03-07 12:46, alaios wrote:
    >
    > Hi I came back with my decent try. Please have a look. I have written
    > the code (at least I tried to be readable by any user.) There you will
    > find points need attention and your comments.
    >
    > Please have a look and comment where is needed


    Do it this way:

    1) Mount the external device.

    2) Then check if it is not mounted, and in that case, bail out, send
    email, whatever. This step is what the snippet of code I posted
    previously does.

    3) Do the backup.

    4) umount the device.

    You can write messages on each step of the process to a file, and at the
    end email that text file. The messages that rsync prints to the screen
    can go instead, or also, to that file, so by reading the email you know
    if rsync succeeded or not.

    Hint: read the rsync manual page, seek for 'exit values'. You can use
    that in scripts.


    Start with a simple script and add to it, by pieces.


    If sending emails to an address in Internet is needed (ie, not on the
    local network), then please start a new thread about that.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 11.4, with Evergreen, x86_64 "Celadon" (Minas Tirith))
    Thanks for the answers. Few comments though:

    I thought I am using mail already in my code so that should be correct.
    Better ways to check that mounts / unmounts worked failed rather than grep technique. Of course I can use already this one given that this is the recommended one.

    Regards
    Alex

Page 4 of 4 FirstFirst ... 234

Posting Permissions

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