//View Tip #362
» Pipe files to an archive
» Change extension on a group of files using only bash builtins an
» CDPATH
» Change prompt color dynamically
Similar Tips
» Find last modified files on a filesystem» Pipe files to an archive
» Change extension on a group of files using only bash builtins an
» CDPATH
» Change prompt color dynamically
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:
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 :)
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 :)


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