//View Tip #362
Similar Tips
» Overwrite a file with zeroes
» Find files greater than a certain size
» Counts files in the current directory and subdirectory
» Fix the previous command
» Alter autocompletion settings

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
If you work on remote boxes a lot, you ll probably need a to backup a directory from there onto your machine sooner or later.. This can easilly be done using ssh & tar; all in 1 line of (script friendly) code:

ssh user@server "cd /foo && tar cvz * --exclude=bar*" > backup.$( date +%y%m%d ).tgz


Substitute user & server by the relevant info; /foo by the map you need and bar with the stuff you dont need; execute the command; login to the server when asked & Blamo! You ll have a nice backup.date.tgz file on your machine :)


View Comments »




Comments 

Add your comment

Comments are currently disabled
bubo
Cool stuff! i thought only lsh can do that like:

bubo@castor:~$ lsh 192.168.0.139  tar cf - /opt2/bubo/musik/[n-s]* | (cd /home/bubo/  && tar -xf -)

by the way: i love this site. thanks a lot for publishing such a huge amount of useful stuff. if you don't believe that look at this:

bubo@castor:~$ grep shell-fu .bashrc
alias shell-fu='w3m -dump http://www.shell-fu.org/lister … php?random | tail -n +27 | tee -a /home/bubo/saveme/shell-fuus.txt'  :-)

regards
Posted 2008-09-19 16:29:10
lsh is an implementation of the ssh v2 protocol, so lsh & ssh have similar features :)
Posted 2008-09-22 14:19:50

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit