2011
07.12

Always wanted to make a tar file without using any local diskspace? This is the solution:

tar zcf - . | pv | ssh foo@bar.com "cat > /data/backup.tgz";

It even has got a progress bar:

163MB 0:00:19 [8,21MB/s] [     < =>     ]

Remember to install pv first:

sudo ap-get install pv

References:

3 comments so far

Add Your Comment
  1. Hi

    What if I want to “get” a tar from remote server and display progress bar. I have this working:

    ssh root@10.0.0.1 “tar -zcpf – / –exclude-caches –exclude=dev –exclude=sys –exclude=mnt –exclude=proc –exclude=sys –exclude=misc –exclude=lost+found –exclude=var/run –exclude=var/spool/squid ” | cat > Backup_$(date +%Y-%m-%d).tgz

    but don’t know how to include pv in this sentence.

    Thank you

  2. replace cat with pv

  3. maomao

    ①ssh command add a param -t
    ②replace cat with pv
    This is an example:
    ssh -t root@x.x.x.x ”
    tar -cf – adirname | pv -s \$(du -sb adirname | awk ‘{print \$1}’) | gzip > adirname.tar.gz
    exit