Distribution: Andere
Version: 5.0
Architektur: 32-Bit PC
Desktop: GNOME
Andere Distribution: Debian

|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#!/usr/bin/perl
# backup.pl -- by Apensiv
use POSIX qw/strftime/;
use File::Copy;
$backup_medium = '/media/R2-D2';
$date = strftime "%d.%m.%Y", localtime;
mkdir ("$backup_medium/backup");
copy('/etc/apt/sources.list', "$backup_medium/backup/");
copy('/etc/X11/xorg.conf', "$backup_medium/backup/");
copy('/etc/fstab', "$backup_medium/backup/");
copy('/etc/samba/smb.conf', "$backup_medium/backup/");
copy('/home/apensiv/.mozilla/firefox/7x14efmv.default/bookmarks.html', "$backup_medium/backup/");
system("tar --remove-files -C $backup_medium -cvf $backup_medium/backup_$date.tar backup");
print "Done\n";
|
Wohnort: Hamburg | Hildesheim
Distribution: Ubuntu
Version: 8.04
Architektur: 32-Bit PC
Desktop: GNOME
Andere Distribution: Gentoo 2008

Zitat
copy('/home/apensiv/.mozilla/firefox/7x14efmv.default/bookmarks.html', "$backup_medium/backup/");
Wohnort: Berlin
Distribution: Ubuntu
Version: 8.04
Architektur: 32-Bit PC
Desktop: GNOME

Wohnort: Bietigheim-Bissingen
Distribution: Andere
Version: WIN 7 x64
Architektur: 64-Bit PC
Desktop: GNOME
|
|
Quellcode |
1 |
dpkg --get-selections | grep -v deinstall > ubuntu-files |
|
|
Quellcode |
1 2 3 4 5 6 7 |
sudo apt-get update sudo apt-get dist-upgrade dpkg --set-selections < ubuntu-files sudo dselect Nach Start von dselect "I" druecken, nach Installation aller Pakete mit "Q" oder "B" (je nach Sprachversion) beenden. |

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »Michael1306« (1. November 2007, 11:39)
User
Wohnort: Hannover
Distribution: Ubuntu
Version: 10.04
Architektur: 32-Bit PC
Desktop: GNOME
Andere Distribution: Debian Etch (Server), yaVDR 0.2.0
Zitat
Original von just_phil
gibt es eine systemvariable, die den aktuellen benutzernamen des eingeloggten users speichert? die könnteste ja an den entscheidenden stellen ins skript eintragen, dann braucht der arme user das nicht selbst zu ändern!![]()
Distribution: Andere
Version: 5.0
Architektur: 32-Bit PC
Desktop: GNOME
Andere Distribution: Debian
Zitat
HOME gibt das Homeverzeichnis des angmeldeten Benutzers aus. Das würde ich eher nehmen. Dann ist Sichergestellt, dass auch das richtige Verzeichnis genommen wird.

User
Wohnort: Hannover
Distribution: Ubuntu
Version: 10.04
Architektur: 32-Bit PC
Desktop: GNOME
Andere Distribution: Debian Etch (Server), yaVDR 0.2.0
Distribution: Andere
Version: 5.0
Architektur: 32-Bit PC
Desktop: GNOME
Andere Distribution: Debian
|
|
Quellcode |
1 |
print $ENV{'HOME'};
|

|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#!/usr/bin/perl
# backup.pl -- by Apensiv
use POSIX qw/strftime/;
use File::Copy;
$home = $ENV{'HOME'} . "/.mozilla/firefox/7x14efmv.default/bookmarks.html";
$backup_medium = '/media/R2-D2';
$date = strftime "%d.%m.%Y", localtime;
mkdir ("$backup_medium/backup");
system("dpkg --get-selections | grep -v deinstall > $backup_medium/backup/ubuntu-files");
copy('/etc/apt/sources.list', "$backup_medium/backup/");
copy('/etc/X11/xorg.conf', "$backup_medium/backup/");
copy('/etc/fstab', "$backup_medium/backup/");
copy('/etc/samba/smb.conf', "$backup_medium/backup/");
copy($home, "$backup_medium/backup/");
system("tar --remove-files -C $backup_medium -cvf $backup_medium/backup_$date.tar backup");
print "Done\n";
|

Wohnort: Berlin
Distribution: Ubuntu
Version: 8.04
Architektur: 32-Bit PC
Desktop: GNOME
Zitat
Original von Apensiv
Ok, die $HOME-Variable funktionierte unter Bash gut.
Für Perl habe ich diesen Befehl nachgeschlagen:
![]()
Quellcode
1print $ENV{'HOME'};
Distribution: Andere
Version: 5.0
Architektur: 32-Bit PC
Desktop: GNOME
Andere Distribution: Debian
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#!/usr/bin/perl
# backup.pl -- by Apensiv
use POSIX qw/strftime/;
use File::Copy;
my @log;
$home = $ENV{'HOME'} . "/.mozilla/firefox/7x14efmv.default/bookmarks.html";
$backup_medium = '/media/APENSIV';
$date = strftime "%d.%m.%Y", localtime;
if (-e "$backup_medium") {
mkdir ("$backup_medium/backup");
system("dpkg --get-selections | grep -v deinstall > $backup_medium/backup/ubuntu-files");
copy('/etc/apt/sources.list', "$backup_medium/backup/");
copy('/etc/X11/xorg.conf', "$backup_medium/backup/");
copy('/etc/fstab', "$backup_medium/backup/");
copy('/etc/samba/smb.conf', "$backup_medium/backup/");
copy($home, "$backup_medium/backup/");
system("tar --remove-files -C $backup_medium -cvf $backup_medium/backup_$date.tar backup");
if (-e "$backup_medium/backup_$date.tar"){
print "Backup erfolgreich erstellt\n";}
else{
print "ERROR: Es konnte kein Backup erstellt werden\n";}}
else{
print "Backupmedium konnte nicht gefunden werden\n";}
|
Wohnort: Hamburg | Hildesheim
Distribution: Ubuntu
Version: 8.04
Architektur: 32-Bit PC
Desktop: GNOME
Andere Distribution: Gentoo 2008
Distribution: Andere
Version: 5.0
Architektur: 32-Bit PC
Desktop: GNOME
Andere Distribution: Debian
|
|
PHP-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
#!/usr/bin/perl -w
# backup.pl -- inspired by Apensiv
# -- by zero77
use strict;
# eingebundene module
use POSIX qw/strftime/; # uhrzeit
#use File::Copy; # betriebssystemunabhaengige file-copy-funktion
my $home = $ENV{'HOME'};
my $backup_medium='/mnt/files/backup';
my $date=strftime "%d_%m_%Y", localtime;
my $progress=0;
if (-e "/dev/disk/by-uuid/41f9f791-bae0-4ae9-9531-922714a9ec8e") { # platte angeschlossen?
if (!-e "$backup_medium") { # platte gemountet?
my $mount=system("mount /mnt/files");
if ($mount==0) { # wenn nicht, mounten
print "Externe USB - Platte gemountet\n";
}
}
print "1) Backup updaten - erstellt komplettes Backup oder bringt Backup up2date\n";
print "2) Tagesstand sichern - erstellt komplettes Backup mit Zeitstempel\n";
print "Bitte wählen: ";
my $method=<STDIN>;
chomp $method;
while ($method ne "1" and $method ne "2") {
print "Bitte wählen (1 oder 2): ";
$method=<STDIN>;
chomp $method;
}
if ($method eq "1") {
$progress=1;
}
else {
$backup_medium=$backup_medium . "/" . $date;
print "ttt: $backup_medium\n";
if (!-e "$backup_medium") { # existiert aktuelles verzeichnis
system("mkdir $backup_medium");
$progress=1;
}
else {
print ("\nVerzeichnis mit aktuellem Datum $date vorhanden\n");
print ("Backup fortsetzen? (ja/nein): ");
my $eingabe=<STDIN>;
chomp $eingabe;
while ($eingabe ne "ja" and $eingabe ne "nein") {
print "ja oder nein: ";
$eingabe=<STDIN>;
chomp $eingabe;
}
if ($eingabe eq "ja") { # update oder ueberschreiben
print ("Update des Backups oder Verzeichnis neu? (upd/neu): ");
my $update=<STDIN>;
chomp $update;
while ($update ne "upd" and $update ne "neu") {
print "upd oder neu: ";
$update=<STDIN>;
chomp $update;
}
if ($update eq "neu") {
print "Entferne altes Backup...\n";
system ("rm -rfv $backup_medium");
system("mkdir $backup_medium");
}
$progress=1;
}
}
}
if ($progress==1) {
if (!-e "$backup_medium/configfiles") {
system("mkdir $backup_medium/configfiles");
}
print "Sichere Daten:\n";
print "sichere Liste der installierten Programme... \n";
system("dpkg --get-selections | grep -v deinstall > $backup_medium/configfiles/ubuntu_files");
print "sichere /etc/apt/sources.list... \n";
system("cp -aru /etc/apt/sources.list $backup_medium/configfiles/");
print "sichere /etc/fstab... \n";
system("cp -aru /etc/fstab $backup_medium/configfiles/");
print "sichere /etc/X11/xorg.conf... \n";
system("cp -aru /etc/X11/xorg.conf $backup_medium/configfiles/");
print "sichere /etc/samba/smb.conf... \n";
system("cp -aru /etc/samba/smb.conf $backup_medium/configfiles/");
print "sichere /home...";
system("cp -aru $home $backup_medium/");
# ...
print "\n Backup beendet\n"
}
else {
print "Beende Backup-Vorgang\n";
}
}
else { # platte nicht angeschlossen
print "Backup-Medium nicht angeschlossen\n";
print "Beende Backup-Vorgang, bitte externe USB-Platte anschließen\n";
print "(UUID des Mediums: 41f9f791-bae0-4ae9-9531-922714a9ec8e)";
}
|
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »zero77« (7. November 2007, 07:01)
User
Wohnort: Hannover
Distribution: Ubuntu
Version: 10.04
Architektur: 32-Bit PC
Desktop: GNOME
Andere Distribution: Debian Etch (Server), yaVDR 0.2.0
Zitat
Original von zero77
hallo zusammen,
![]()
PHP-Quelltext
1if (-e "/dev/disk/by-uuid/41f9f791-bae0-4ae9-9531-922714a9ec8e") { # platte angeschlossen?
Das Script soll prüfen, ob die externe Platte angeschlossen und gemountet ist.
User
Wohnort: Hannover
Distribution: Ubuntu
Version: 10.04
Architektur: 32-Bit PC
Desktop: GNOME
Andere Distribution: Debian Etch (Server), yaVDR 0.2.0

Distribution: Andere
Version: 5.0
Architektur: 32-Bit PC
Desktop: GNOME
Andere Distribution: Debian

|
|
Quellcode |
1 |
./backup.pl -add /etc/httpd/httpd.conf -comment blablabla |
Zitat
Vielleicht kann mir ja auch jemand sagen, wie man es besten bewerkstelligen kann, dass er das Backup-Verzeichnis mit den Quellverzeichnissen abgleicht und da die Dateien entfernt, die es in den Quellen nicht mehr gibt.
User
Wohnort: Schweiz
Distribution: Ubuntu
Version: 10.04
Architektur: 32-Bit PC
Desktop: GNOME
Zitat
Vielleicht kann mir ja auch jemand sagen, wie man es besten bewerkstelligen kann, dass er das Backup-Verzeichnis mit den Quellverzeichnissen abgleicht und da die Dateien entfernt, die es in den Quellen nicht mehr gibt.
|
| Computer mit vorinstalliertem Linux: Ubuntu, Kubuntu, Xubuntu, Mythbuntu u.a. |
Impressum
Forensoftware: Burning Board®, entwickelt von WoltLab® GmbH
Lastminute - Branchenverzeichnis - Portugal Branchenverzeichnis - Zahnimplantate
Skiurlaub - Rezepte - Ausschankwagen - Kochrezepte
T-Shirts - Winterurlaub - Kontaktanzeigen - Computer Forum - Linux Computer