first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / scripts / archival / snarf_linux_config.pl
1 #!/usr/bin/perl
2
3 ##############
4 #  Name   : snarf_linux_config
5 #  Author : Chris Koeritz
6 #  Rights : Copyright (C) 1996-$now by Author
7 #  Purpose:
8 #    Backs up the useful linux config files and names the file after the
9 #  host it's run on.
10 ##############
11 #  This program is free software; you can redistribute it and/or modify it
12 #  under the terms of the GNU General Public License as published by the Free
13 #  Software Foundation; either version 2 of the License or (at your option)
14 #  any later version.  See: "http://www.gruntose.com/Info/GNU/GPL.html" for a
15 #  version of the License.  Please send any updates to "fred@gruntose.com".
16 ##############
17
18 require "importenv.pl";
19 require "shared_snarfer.pl";
20
21 &initialize_snarfer;
22
23 # get the number we use and increment it for the next use.
24 local($number) = &retrieve_number("aa_backup");
25
26 # variables used throughout.
27 local($base) = snarf_prefix("linux_config");
28 local($snarf_file) = &snarf_name($base, $number);
29
30 # store the current archive number in the file for retrieval on the
31 # other side.
32 &backup_number("aa_backup", $base, $number);
33
34 # write a little file showing the disk status.
35 local($infofile) = $HOME . "/disk_info.txt";
36 unlink $infofile;
37 open(INF, ">>" . $infofile);
38 print INF "Current mount configuration:\n";
39 print INF "\n";
40 close(INF);
41 system("mount >>$infofile");
42 open(INF, ">>" . $infofile);
43 print INF "\n";
44 print INF "\n";
45 print INF "Current disk configuration:\n";
46 print INF "\n";
47 close(INF);
48 system("fdisk -l >>$HOME/disk_info.txt");
49 &backup_files($base, $number, $HOME, ".", ("disk_info.txt"));
50 unlink $infofile;
51
52 # backup the dpkg info.
53 &backup_files($base, $number, "/", "var/lib/dpkg", ("status*"));
54
55 # backup the crucial hierarchies in /var...
56 &backup_hierarchy($base, $number, "/", "var/named");
57 ###not good: &backup_hierarchy($base, $number, "/", "var/lib/mysql");
58 ###the mysql snarf is not necessarily usable, since we really should be
59 ###backing up the databases by another means than this.
60 &backup_hierarchy($base, $number, "/", "var/lib/named/master");
61 &backup_hierarchy($base, $number, "/", "var/lib/webalizer");
62
63 # snag the grub bootloader files.
64 &backup_hierarchy($base, $number, "/", "boot/grub");
65
66 # now get the entire /etc hierarchy...
67 &backup_hierarchy($base, $number, "/", "etc");
68
69 # clean out extra files.
70 &remove_from_backup($base, $number, "etc/cups/ppds.dat*");
71 &remove_from_backup($base, $number, "etc/httpd/conf/ssl.crt/ca-bundle.crt");
72 &remove_from_backup($base, $number, "etc/locale/*");
73 &remove_from_backup($base, $number, "etc/opt/kde3/share/services/ksycoca");
74 &remove_from_backup($base, $number, "etc/preload.d/*");
75 &remove_from_backup($base, $number, "etc/rmt");
76 &remove_from_backup($base, $number, "etc/termcap");
77 &remove_from_backup($base, $number, "etc/X11/X");
78 &remove_from_backup($base, $number, "etc/X11/xkb/*");
79 &remove_from_backup($base, $number, "*.bak");
80 &remove_from_backup($base, $number, "*.cache");
81 &remove_from_backup($base, $number, "*.crt");
82 &remove_from_backup($base, $number, "*.old");
83 &remove_from_backup($base, $number, "*.schemas");
84 &remove_from_backup($base, $number, "*.so");
85 &remove_from_backup($base, $number, "*.xml");
86
87 # now rename the file so only the unpacker can access it.
88 &rename_archive($snarf_file);
89
90 exit 0;
91