sup icon indicating copy to clipboard operation
sup copied to clipboard

Uploading with rsync

Open eduardonunesp opened this issue 9 years ago • 4 comments

Hey everyone, I managed to upload my src files using rsync instead using the native option (tar), so I want to show my Supfile and to share my idea, I hope that action bring new ideas and show how much Sup is a cool and flexible option.

version: 0.3

env:
  TMP_DIR: /tmp/mydir
  DEV_USER: docker
  DEV_HOST: 192.168.99.100

networks:
  local:
    hosts:
      - localhost

  dev:
    hosts:
      - [email protected]

commands:
  ping:
    desc: Print uname and current date/time.
    run: uname -a; date

  pre-build:
    run: mkdir $TMP_DIR; exit 0

  rsync:
    local: rsync -aczP src/ $DEV_USER@$DEV_HOST:$TMP_DIR

  remote-test:
    run: $TMP_DIR/test.sh

targets:
  deploy:
    - ping
    - pre-build
    - rsync
    - remote-test
[email protected]:22 | + uname -a
[email protected]:22 | + date
[email protected]:22 | Linux dev 4.1.19-boot2docker #1 SMP Mon Mar 7 17:44:33 UTC 2016 x86_64 GNU/Linux
[email protected]:22 | Thu Apr 14 02:32:29 UTC 2016
[email protected]:22 | + mkdir /tmp/mydir
[email protected]:22 | + exit 0
eduardonunesp@localhost | + rsync -aczP src/ [email protected]:/tmp/mydir
eduardonunesp@localhost | building file list ...
2 files to considerhost |  0 files...
eduardonunesp@localhost | ./
eduardonunesp@localhost | test.sh
          45 100%    0.00kB/s    0:00:00 (xfer#1, to-check=0/2):00
eduardonunesp@localhost |
eduardonunesp@localhost | sent 210 bytes  received 48 bytes  172.00 bytes/sec
eduardonunesp@localhost | total size is 45  speedup is 0.17
[email protected]:22 | + /tmp/mydir/test.sh
[email protected]:22 | REMOTE DATE Thu Apr 14 02:32:30 UTC 2016

Important to note: rsync command is working in local src directory and the ssh address is using environment variables (created inside the Supfile). Well, it would be cool if we had some way to get array of hosts like we have the SUP_NETWORK for instance.

eduardonunesp avatar Apr 14 '16 02:04 eduardonunesp

About the current host used, never mind, I found the SUP_HOST variable, which inform the current host. Just need to add in README :neckbeard:

Unfortunately the SUP_HOST doesn't make difference in this case, because when rsync runs the current host is localhost. :cry:

eduardonunesp avatar Apr 14 '16 11:04 eduardonunesp

Is it possible to create an intermediary command, just to inject variables at the global ? something like:

  trick:
    export: TRICK_ENV=$SUP_HOST

  rsync:
    local: rsync -aczP src/ $TRICK_ENV:$TMP_DIR

targets:
  deploy:
    - trick
    - rsync

I know that command export doesn't exists, but it's just an option to set some variable at runtime. Actually if I have more then one host it need to have an option to run the local rsync for each host as well.

eduardonunesp avatar Apr 14 '16 13:04 eduardonunesp

It would be great to have option to use rsync in upload, like:

commands:
    upload:
        desc: Upload dist files to all hosts
        upload:
          - src: ./dist
            dst: /tmp/
        uploader: rsync

hauleth avatar Aug 08 '16 12:08 hauleth

I am interested in being able to pass name of the current remote computer, so I command like the following can be written against all computers and not hardcoded to one:

rsync:
  local: rsync -aczP src/ $each_remote_computer_name:$HOME/blah

I could not figure out if there is already a built-in variable that reflects the name of current remote computer connection.

kulak avatar Mar 14 '17 21:03 kulak