Results 1 to 4 of 4

Thread: rsync --read-batch over ssh

  1. #1
    Join Date
    May 2006
    Location
    Amsterdam
    Beans
    1,731
    Distro
    Ubuntu 10.10 Maverick Meerkat

    rsync --read-batch over ssh

    Hello all,

    I have a question regarding rsync --read-batch=file over ssh.

    I'm doing the following:

    Code:
    function exec_rsync() {
        local host=$1
        shift
        ssh $host mkdir -p $src
        eval sudo rsync --write-batch=/tmp/rsync_disk $rsync_opts -e "'ssh'" $DIRS "'user@${host}:$src'"
    #    eval sudo rsync $rsync_opts -e "'ssh'" $DIRS "'user@${host}:$src'"
        [ $? -ne 0 ] && exit 1
    
        for host in $* ; do
            ssh $host mkdir -p $src
    #        eval sudo rsync $rsync_opts -e "'ssh'" $DIRS "'user@${host}:$src'"
            eval sudo rsync --read-batch=/tmp/rsync_disk $rsync_opts -e "'ssh'" $DIRS "'user@${host}:$src'"
            [ $? -ne 0 ] && exit 1
        done
    }
    When I execute the script, I get the following error:

    Code:
    (zsh)$ rsync_disks host host2     
    user@host password: 
    building file list ... 
    14498 files to consider
    [snip]
    sent 414055 bytes  received 60 bytes  75293.64 bytes/sec
    total size is 34045203836  speedup is 82211.96
    remote destination is not allowed with --read-batch
    rsync error: syntax or usage error (code 1) at main.c(1218) [Receiver=3.0.9]
    Can someone tell me what I'm doing wrong, if I should be setting up an rsync daemon because batch-files aren't supported over ssh, etc?
    Upgrade Ubuntu | Upgrade unsupported Ubuntu versions | Always backup | Howto upgrade flash
    Minimal CD install | Remove old kernels | My blog | Linux user #462801 | Conscience doth make cowards of us all. -- Shakespeare

  2. #2
    Join Date
    Nov 2006
    Location
    Belgium
    Beans
    3,007
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: rsync --read-batch over ssh

    I'm not familiar with the batch options, but at first glance it looks to me that batch mode is rather a special case thet requires a rather different approach that 'rsync this there'

    Have you read the BATCH MODE section in the man page ?

  3. #3
    Join Date
    May 2006
    Location
    Amsterdam
    Beans
    1,731
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: rsync --read-batch over ssh

    Quote Originally Posted by koenn View Post
    I'm not familiar with the batch options, but at first glance it looks to me that batch mode is rather a special case thet requires a rather different approach that 'rsync this there'

    Have you read the BATCH MODE section in the man page ?
    Yes I did, but I expected similar syntax as to the rsync over ssh, as you see in my code snippet.

    Now I'm doing this and it works:

    Code:
    function exec_rsync() {
        local batch_file=/tmp/rsync_disk
        local host=$1
        local user=someuser
    
        if [ ! -e $batch_file ] ; then
            eval sudo rsync --only-write-batch=$batch_file $rsync_opts $DIRS -e 'ssh' $user@$host:$src
            [ $? -ne 0 ] && exit 1
        fi
    
        for host in $* ; do
            sudo cat $batch_file | eval ssh $user@$host rsync $rsync_opts --read-batch=- $src
            [ $? -ne 0 ] && exit 1
        done
        sudo rm $batch_file
    }
    Upgrade Ubuntu | Upgrade unsupported Ubuntu versions | Always backup | Howto upgrade flash
    Minimal CD install | Remove old kernels | My blog | Linux user #462801 | Conscience doth make cowards of us all. -- Shakespeare

  4. #4
    Join Date
    Nov 2006
    Location
    Belgium
    Beans
    3,007
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: rsync --read-batch over ssh

    Good job.

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
  •