Find the answer to your Linux question:
Results 1 to 2 of 2
Box 1 = client Box 2 = server Protocol: SSH I think my scripts might conflict. They might conflict on the hour. I'm using cronjobs. Maybe some of you can ...
  1. #1
    Linux User Agent-X's Avatar
    Join Date
    May 2005
    Location
    Dimension X
    Posts
    261

    Unhappy Client-server ssh, possibility of cron job conflicts

    Box 1 = client
    Box 2 = server
    Protocol: SSH

    I think my scripts might conflict.
    They might conflict on the hour.
    I'm using cronjobs.

    Maybe some of you can look at them and get an idea of what I mean.
    I'm not too sure how to explain it.
    There might be the possibility that whichever script gets loaded first will win.

    I don't like that.

    How do I make sure these scripts don't conflict on the hour?

    I tried doing some flagon file, but I don't think that's good enough.


    I think if I could do something like...
    if [ -e root@101.101.101.101:/ramdisk/.serverflags/backupinprocess ]
    then
    exit
    else
    keep on truckin'
    fi
    ...then things would be ok.
    Am I able to do that?
    I haven't tried it, but if it doesn't, that's why I posted here.

    * I just tried it. It didn't work.
    :/

    Box 1's script every half hour...

    Code:
    #!/bin/sh
    if [ -e /home/box1firetwo/scripts/archival/checks/backup-to-RAM ]
    then
    exit
    else
    echo "1" > /home/box1firetwo/scripts/archival/checks/backup-to-RAM
    ssh someuser@101.101.101.101 'umount /ramdisk'
    ssh someuser@101.101.101.101 'umount /ramdisk'
    umount /ramdisk
    ssh someuser@101.101.101.101 'mount /ramdisk'
    mount /ramdisk
    ssh someuser@101.101.101.101 'echo "1" > /ramdisk/.serverflags/flagon'
    cp -a --parents /home/box1firetwo/important /ramdisk
    cp -a --parents /home/box1firetwo/Desktop/.misc /ramdisk
    scp -r -p /ramdisk/home someuser@101.101.101.101:/ramdisk
    umount /ramdisk
    rm /home/box1firetwo/scripts/archival/checks/backup-to-RAM
    clear
    fi
    * /home/box1firetwo/scripts/archival/checks/backup-to-RAM is to prevent other backup scripts on the client from trying to access the server's ramdisk folder.

    Box 2's every 4 hours and 15 minutes script:

    Code:
    universe:~# cat /home/someuser/scripts/backuptolexar 
    #!/bin/sh
    if [ -e /ramdisk/.serverflags/flagon ]
    then
    exit
    else
    cp -a --parents /ramdisk/home/box1firetwo/important /media/lexar
    fi

  2. #2
    Linux User
    Join Date
    May 2008
    Location
    NYC, moved from KS & MO
    Posts
    251
    In your box1 script, you use
    ssh someuser@101.101.101.101 'echo "1" > /ramdisk/.serverflags/flagon'
    to set the backup-in-progress flag onto box2 but you never remove that flag when the back up is finished.

    You need to add
    ssh someuser@101.101.101.101 rm -f /ramdisk/.serverflags/flagon
    after the line
    rm /home/box1firetwo/scripts/archival/checks/backup-to-RAM

    Box 2's ramdisk can only hold last 15minutes' data from box1 since it's being umounted and mounted every 15 minutes.

    For your script, I would suggest the followings:
    1. Get rid of the use of ramdisk unless the network speed is super fast that you want to take advantage of it. You just backup whatever from source to destination without box2's script running.
    2. rsync would be a better choice (to replace scp) for backing data
    3. You can also try boxbackup, which is not easy but it has features such as backup on file change. (You don't need any additional scripts, its backup run in daemon mode.)

Posting Permissions

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