wikiv3:comando-tar
Table of Contents
Comando tar
Para empacotar
$ tar -cpvf fontes.tar /usr/share/fonts/
Para lista
$ tar -tpvf fontes.tar
Para extrair
$ tar -xpvf fontes.tar
Exclusão de arquivo
$ touch arquivo{0..9}.txt $ tar -cpvf todos.tar * $ tar --delete arquivo8.txt -f todos.tar $ tar -tpvf todos.tar
ou
$ cat excluidos.txt
arquivo2.txt
arquivo4.txt
$ tar --delete -T excluidos.txt -f todos.tar $ tar -tpvf todos.tar
Exclusão de diretórios
$ mkdir diretorio{0..9} $ cat excluidir.txt diretorio2 diretorio4
$ tar --exclude-from=excluidir.txt -cpvf diretorios.tar diretorio*
Concatenando
$ tar -Af todos.tar diretorios.tar $ tar -tvpf todos.tar
$ tar -A todos.tar -A diretorios.tar -A fontes.tar -f bkp.tar
Anexando arquivos a um .tar
$ tar -r todos.tar -f diretorios.tar
Backups locais
$ tar --force-local -cpvf diretorios-$(/bin/date '+%Y-%m-%d-%H:%M').tar diretorio*
Bacups remotos
# rsync -avpz dns41.laboratorio.com.br:named.tar /tmp/
Exemplo de backup remoto (script)
# cat backup.sh #!/bin/bash PATH=/usr/bin:/usr/sbin/:/bin:/sbin clear echo "Aguarde... realizando backup" rsync -avz --password-file=/root/rsyncpw gean@dns41.laboratorio.com.br:/backup/ /mnt/backups/ echo "Fim..."
wikiv3/comando-tar.txt · Last modified: by 127.0.0.1
