]>
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') { | |
8e8bbd9d CS |
17 | &createinclude; |
18 | my @files = `find / -name *.log`; | |
19 | foreach (@files){ | |
20 | push(@include,$_); | |
21 | } | |
22 | open(DATEI, ">/tmp/include") || die "Could not save temp include file"; | |
23 | print DATEI @include; | |
24 | close(DATEI); | |
25 | system("tar -cvzf /srv/web/ipfire/html/backup/$Jahr$Monat$Monatstag-$Stunden:$Minuten.ipf --files-from=/tmp/include --exclude-from=/var/ipfire/backup/exclude"); | |
26 | system("rm /tmp/include"); | |
27 | } | |
28 | ||
29 | if ($ARGV[0] eq 'exclude') { | |
cf29614f CS |
30 | &createinclude; |
31 | open(DATEI, ">/tmp/include") || die "Could not save temp include file"; | |
32 | print DATEI @include; | |
33 | close(DATEI); | |
8e8bbd9d | 34 | system("tar -cvzf /srv/web/ipfire/html/backup/$Jahr$Monat$Monatstag-$Stunden:$Minuten.ipf --files-from='/tmp/include' --exclude-from='/var/ipfire/backup/exclude'"); |
cf29614f CS |
35 | system("rm /tmp/include"); |
36 | } | |
37 | ||
8e8bbd9d CS |
38 | if ($ARGV[0] eq 'restore') { |
39 | system("tar -xvz --preserve -f /tmp/restore.ipf"); | |
40 | } | |
41 | ||
cf29614f CS |
42 | if ($ARGV[0] eq 'exclude') { |
43 | &createinclude; | |
44 | open(DATEI, ">/tmp/include") || die "Could not save temp include file"; | |
45 | print DATEI @include; | |
46 | close(DATEI); | |
8e8bbd9d | 47 | system("tar -cvzf /srv/web/ipfire/html/backup/$Jahr$Monat$Monatstag-$Stunden:$Minuten.ipf --files-from='/tmp/include' --exclude-from='/var/ipfire/backup/exclude'"); |
cf29614f CS |
48 | system("rm /tmp/include"); |
49 | } | |
50 | ||
8e8bbd9d CS |
51 | if ($ARGV[0] eq 'cli') { |
52 | system("tar -cvzf /srv/web/ipfire/html/backup/$Jahr$Monat$Monatstag-$Stunden:$Minuten-$ARGV[1].ipf --files-from='$ARGV[2]' --exclude-from='$ARGV[3]'"); | |
53 | } | |
54 | ||
55 | if ($ARGV[0] eq '') { | |
56 | printf "No argument given, please use <include><exclude>\n" | |
57 | } | |
58 | ||
cf29614f CS |
59 | sub createinclude(){ |
60 | ||
61 | open(DATEI, "<${General::swroot}/backup/include") || die "Can not open include file"; | |
62 | my @Zeilen = <DATEI>; | |
63 | close(DATEI); | |
64 | ||
65 | foreach (@Zeilen){ | |
66 | if ( $_ =~ /\*/){ | |
67 | my @files = `ls $_`; | |
68 | foreach (@files){ | |
69 | push(@include,$_); | |
8e8bbd9d CS |
70 | } |
71 | } | |
cf29614f CS |
72 | else {push(@include,$_);} |
73 | } | |
74 | } |