shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [shell-script] Script com comando Tar


From: Herbert Alexander Faleiros
Subject: Re: [shell-script] Script com comando Tar
Date: Sun, 9 Jul 2006 14:09:20 -0300
User-agent: KMail/1.9.3

On Sunday 09 July 2006 12:45, Herbert Alexander Faleiros wrote:
[cut]
> size=`du -s "$1" | awk '{print $1}'`
> disc=`expr 50 \* 1024`
>
> for i in `seq 0 $(expr $size / $disc)`; do
>   vols=$vols$(echo -n "-f disc$(printf %03d $i).tar ")
> done
>
> tar -c $vols -M -L $disc "$1"
[cut]

A GPL é para garantir que não vá encontrar o script em algum lugar na net com 
outro autor (acreditem, isso acontece).

Ah, só copiei/colei (o script/explicações) de um outro e-mail que escrevi no 
início do ano em uma lista de Linux (não recordo qual foi).

Outra coisa, se não me engano (não tenho certeza) o tar aguenta até 68G e o 
cpio 8G, talvez a limitação que citou seja do sistema de arquivos.

Melhorando um pouquinho o script (tornando-o funcional):

#!/bin/sh
#
# backup - tar with multi-volumes (files).
# Copyright (C) 2006 Herbert Alexander Faleiros
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Herbert Alexander Faleiros aka ratmmmam <address@hidden>
#

# disc size
default=50

function create() {

  size=`du -s "$1" | awk '{print $1}'`
  disc=`expr $default \* 1024`

  for i in `seq 0 $(expr $size / $disc)`; do
    vols=$vols$(echo -n "-f disc$(printf %03d $i).tar ")
  done

  tar -P -c $vols -M -L $disc "$1"
}

function restore() {

  for i in disc*; do
    vols=$vols$(echo -n "-f $i ");
  done;

  tar -x $vols -M
}

case $1 in
  create)
    create $2
  ;;
  restore)
    restore
  ;;
  *)
    echo "Usage: $0 create|restore dir/file"
    exit 1
  ;;
esac


reply via email to

[Prev in Thread] Current Thread [Next in Thread]