]>
Commit | Line | Data |
---|---|---|
cf29614f CS |
1 | #!/usr/bin/perl |
2 | ||
3 | require '/var/ipfire/general-functions.pl'; | |
4 | require "${General::swroot}/lang.pl"; | |
5 | require "${General::swroot}/header.pl"; | |
6 | ||
7 | my $debug = 1; | |
8 | my @include = ""; | |
9 | my ($Sekunden, $Minuten, $Stunden, $Monatstag, $Monat, $Jahr, $Wochentag, $Jahrestag, $Sommerzeit) = localtime(time); | |
10 | $Jahr = $Jahr + 1900;$Monat = $Monat + 1; | |
11 | $Monat = sprintf("%02d", $Monat); | |
12 | $Monatstag = sprintf("%02d", $Monatstag); | |
13 | $Stunden = sprintf("%02d", $Stunden); | |
14 | $Minuten = sprintf("%02d", $Minuten); | |
15 | ||
16 | if ($ARGV[0] eq 'include') { | |
17 | &createinclude; | |
18 | open(DATEI, ">/tmp/include") || die "Could not save temp include file"; | |
19 | print DATEI @include; | |
20 | close(DATEI); | |
21 | system("tar -cvzf /var/ipfire/backup/$Jahr$Monat$Monatstag-$Stunden:$Minuten.ipf --files-from=/tmp/include --exclude-from=/var/ipfire/backup/exclude"); | |
22 | system("rm /tmp/include"); | |
23 | } | |
24 | ||
25 | if ($ARGV[0] eq 'exclude') { | |
26 | &createinclude; | |
27 | open(DATEI, ">/tmp/include") || die "Could not save temp include file"; | |
28 | print DATEI @include; | |
29 | close(DATEI); | |
30 | system("tar -cvzf /var/ipfire/backup/$Jahr$Monat$Monatstag-$Stunden:$Minuten.ipf --files-from='/tmp/include' --exclude-from='/var/ipfire/backup/exclude'"); | |
31 | system("rm /tmp/include"); | |
32 | } | |
33 | ||
34 | sub createinclude(){ | |
35 | ||
36 | open(DATEI, "<${General::swroot}/backup/include") || die "Can not open include file"; | |
37 | my @Zeilen = <DATEI>; | |
38 | close(DATEI); | |
39 | ||
40 | foreach (@Zeilen){ | |
41 | if ( $_ =~ /\*/){ | |
42 | my @files = `ls $_`; | |
43 | foreach (@files){ | |
44 | push(@include,$_); | |
45 | } | |
46 | } | |
47 | else {push(@include,$_);} | |
48 | } | |
49 | } |