#!/usr/bin/perl # # Copyright (C) 2001 by Sebastien DUPONT # Redistribution of this file is permitted under the terms of the GNU # Public License (GPL) ## description: # # Drakbacup is use to backup system files and user files # Drakbacup allow to restore the system (etc, var files) # from starup or on drakconf utility. # #backup name format: all the time from the / # backup_sys_12102001.tar.gz -> default system backup # backup_sys_etc_var_proc_12102001.tar.gz -> specific system directories # backup_user_james_12102001.tar.gz -> default user backup # backup_user_james_documents_12102001.tar.gz -> specific user directories # backup_other_proc_12102001.tar.gz -> specific other directories # # backup name rules: system: begin by sys # user: begin by user # other: begin by other # end of all `date`.tar.gz # # seems to be good idea to have a txt file where user explain the differences # between all the backup # # save only the differences... # find / -mtime -1 \! -type d -print > /tmp/liste.jour # # build iso fs with rescue. # # configuration file on /etc/drakconf/drakbackup/drakbakup.conf # use Gtk; use lib qw(/usr/lib/libDrakX ); use interactive; use standalone; use my_gtk qw(:helpers :wrappers); use common; use strict; if ("@ARGV" =~ /--help|-h/) { print q(Backup and monitoring application --list : list of files or directories to backup. --default : save default directories. --build_cd : build restore iso with the currents backups files & rescue options. --build_floppy : build restore floppy. --update : don t replace the old backup, only update it. --replace : delete backup files before build new. --save_dir : by default the backup files are saved in in /var/backup directory so write other directory to change to change it. --conf_file : to read other configuration file. ); exit(0); } # Backend Options. my $default = 0; my $build_cd = 0; my $build_floppy = 0; my $comp_mode = 0; my $mode = 0; my $replace = 0; my $update = 0; my $conf_file = 0; my @list_arg = (); my @sys_files ; my @home_files; my @other_files; my $save_path; my $option_replace = 0; my $option_update = 0; my $windows = 0; my $central_widget; my $interactive; my $up_box; my $box; # PATH & Global variables. my $cfg_file = "/etc/drakconf/drakbackup/drakbackup.conf"; foreach (@ARGV) { /--default/ and $default = 1, $mode=-1; /--build_cd/ and $build_cd = 1, $mode=-1; /--build_floppy/ and $build_floppy = 1, $mode=-1; /--replace|-r/ and $replace = 1, $mode=-1; /--update|-u/ and $update = 1, $mode=-1; /--conf_file/ and $mode = 0, next; # $mode == 0 and push $conf_file, $_; /--list/ and $mode = 1, next; $mode == 1 and push @list_arg, $_; } sub debug { print "SYS_FILES: $_ \n" foreach (@sys_files); print "HOME_FILES: $_ \n" foreach (@home_files); print "OTHER_FILES: $_ \n" foreach (@other_files); print "PATH_TO_SAVE: $save_path \n"; print "OPTION_REPLACE: $option_replace \n"; print "OPTION_UPDATE: $option_update \n"; print "OPTION_COMP: $comp_mode \n"; } my @xpm_data = ( "16 16 4 1", " c None s None", ". c black", "X c #808080", "o c white", " ", " .. ", " .Xo. ... ", " .Xoo. ..oo. ", " .Xooo.Xooo... ", " .Xooo.oooo.X. ", " .Xooo.Xooo.X. ", " .Xooo.oooo.X. ", " .Xooo.Xooo.X. ", " .Xooo.oooo.X. ", " .Xoo.Xoo..X. ", " .Xo.o..ooX. ", " .X..XXXXX. ", " ..X....... ", " .. ", " "); sub read_conf_file { foreach (cat_("$cfg_file")) { if (/^SYS_FILES/) { chomp; s/^SYS_FILES=//gi; @sys_files = split(' ', $_ ); } if (/^HOME_FILES/) { chomp; s/^HOME_FILES=//gi; @home_files = split(' ', $_ ); } if (/^OTHER_FILES/) { chomp; s/^OTHER_FILES=//gi; @other_files = split(' ', $_ ); } if (/^PATH_TO_SAVE/) { chomp; $save_path = $_; } if (/^OPTION_REPLACE/){ $option_replace = 1; $option_update = 0; } if (/^OPTION_UPDATE/){ $option_replace = 0; $option_update = 1; } if (/^OPTION_COMP/) { chomp; s/^OPTION_COMP=//gi; /TAR.GZ/ and $comp_mode = 0; /TAR.BZ2/ and $comp_mode = 1; } } debug; } $build_floppy || $build_cd || $default || @list_arg || $conf_file ? backend_mod() : interactive_mode(); sub backend_mod { read_conf_file(); } sub build_cd_fct { } sub build_floppy_fct { } sub build_backup_files { } sub interactive_mode { my $fst_choice_box; my $fst_choice_box1; my $pixmap_fst_choice; $interactive = 1; my $pixmap; my $pixmapwid; my $mask; my $style; my $box; init Gtk; my $window1 = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel; $window1->signal_connect (delete_event => sub { Gtk->exit(0) }); $window1->set_position(1); $window1->set_title(_("Drakbackup")); my ($pix_u_map, $pix_u_mask) = gtkcreate_png("pixmaps/backup_title.png"); my ($pix_l_map, $pix_l_mask) = gtkcreate_png("pixmaps/backup_left.png"); my ($pix_r_map, $pix_r_mask) = gtkcreate_png("pixmaps/backup_bot.png"); gtkadd($window1, gtkpack(new Gtk::VBox(0,0), gtkpack(new Gtk::VBox(0,0), new Gtk::Pixmap($pix_u_map, $pix_u_mask), gtkpack_(new Gtk::HBox(0,0), 0, new Gtk::Pixmap($pix_l_map, $pix_l_mask), 1, gtkpack($up_box = new Gtk::VBox(0,5),#gtkset_usize($up_box = new Gtk::VBox(0,5),321, 230), $box = gtkpack(new Gtk::VBox(0,0), _("Please choose the method to configure your system backup."), gtkpack(new Gtk::HBox(0,20), gtkpack(new Gtk::VBox(0,10), new Gtk::HBox(0,15), my $adv_c_button = new Gtk::RadioButton (_("Advanced")), # my $wiz_h_button = new Gtk::RadioButton _("Wizard"), $adv_c_button, new Gtk::HBox(0,5), ), ), ), ), ), new Gtk::Pixmap($pix_r_map, $pix_r_mask), gtkadd(gtkset_layout(new Gtk::HButtonBox, -end), gtksignal_connect(new Gtk::Button(_("Close")), clicked => sub { Gtk->main_quit() }), gtksignal_connect(new Gtk::Button(_("About")), clicked => sub { ${$central_widget}->destroy(); about() }), gtksignal_connect(new Gtk::Button(_(" Help ")), clicked => sub { ${$central_widget}->destroy(); help() }), gtksignal_connect(new Gtk::Button(_("Next")), clicked => sub { ${$central_widget}->destroy(); about() }), ), ), ), ); $central_widget = \$box; $window1->show_all; $window1->realize; $window1->show_all(); Gtk->main; Gtk->exit(0); } sub about { my $text = new Gtk::Text(undef, undef); my $about_box; gtkpack($up_box, $about_box = gtkpack_(new Gtk::VBox(0,10), 1, gtkpack_(new Gtk::HBox(0,0), 1, gtktext_insert(gtkset_editable($text, 1), _(" Copyright (C) 2001 by MandrakeSoft (sdupont\@mandrakesoft.com) 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, 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. ")), 0, new Gtk::VScrollbar($text->vadj), ), 0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -spread), gtksignal_connect(new Gtk::Button(_("OK")), clicked => sub { ${$central_widget}->destroy(); }), ), ) ); $central_widget = \$about_box; $up_box->show_all(); } sub help { my $text = new Gtk::Text(undef, undef); my $about_box; gtkpack($up_box, $about_box = gtkpack_(new Gtk::VBox(0,10), 1, gtkpack_(new Gtk::HBox(0,0), 1, gtktext_insert(gtkset_editable($text, 1), _(" description: Drakbacup is use to backup system files and user files Drakbacup allow to restore the system (etc, var files) from starup or on drakconf utility. backup name format: all the time from the / dir. system backup: backup_sys_12102001.tar.gz backup_sys_etc_var_proc_12102001.tar.gz user backup backup_user_james_12102001.tar.gz backup_user_james_documents_12102001.tar.gz other directories backup_other_proc_12102001.tar.gz backup name rules: system: begin by sys user: begin by user other: begin by other end of all `date`.tar.gz save only the differences... find / -mtime -1 \! -type d -print > /tmp/liste.jour build iso fs with rescue. configuration file: /etc/drakconf/drakbackup/drakbakup.conf ")), 0, new Gtk::VScrollbar($text->vadj), ), 0, gtkadd(gtkset_layout(new Gtk::HButtonBox, -spread), gtksignal_connect(new Gtk::Button(_("OK")), clicked => sub { ${$central_widget}->hide(); }), ), ) ); $central_widget = \$about_box; $up_box->show_all(); } sub wizard { my $wizard_box; gtkpack($up_box, new Gtk::VBox(0,10), $wizard_box = new Gtk::FontSelection, ); $central_widget = \$wizard_box; $up_box->show_all(); } sub advanced { } # my $checkbutton = new Gtk::CheckButton( "Check me please!" ); # $checkbutton->set_usize( 100, 75 ); # $checkbutton->show(); # $pixmap_fst_choice = new Gtk::Notebook, # my $label1 = new Gtk::Label( "What backup." ); # my $label2 = new Gtk::Label( "Where backup." ); # my $label3 = new Gtk::Label( "When backup." ); # # gtkadd($window1, # gtkpack_(new Gtk::VBox(0,2), # 1, gtkpack_(new Gtk::VBox(0,2), # 1, new Gtk::VBox(0,0), # 1, gtkpack(gtkset_usize($notebook_box = new Gtk::VBox(0,5),500, 350), # $notebook = new Gtk::Notebook, # $notebook->insert_page( $checkbutton, $label1, 2 ), # $notebook->insert_page( $checkbutton, $label2, 2 ), # $notebook->insert_page( $checkbutton, $label3, 2 ) # ), # 1, new Gtk::VBox(0,0) # ), # 0, gtkpack_(new Gtk::HBox(0,5), # 1, new Gtk::HBox(0,0), # 1, gtkadd(gtkset_layout(new Gtk::HButtonBox, -end), # gtksignal_connect(new Gtk::Button(_("Help")), clicked => sub { # ${$central_widget}->destroy(); help() }), # gtksignal_connect(new Gtk::Button(_("About")), clicked => sub { # ${$central_widget}->destroy(); help() }), # gtksignal_connect(new Gtk::Button(_("Close")), clicked => sub { Gtk->main_quit() }), # ), # ) # ), # ); #________________________________________________________________________________________________________ # 0, _("DrakFont"), # 0, gtkadd(gtkset_layout(new Gtk::VButtonBox, -end), # gtksignal_connect(new Gtk::Button(_("Windows Importation")), clicked => # sub { ${$central_widget}->destroy(); $windows = 1; license(\&appli_choice)}), # gtksignal_connect(new Gtk::Button(_("Configuration")), clicked => # sub { ${$central_widget}->destroy(); $windows = 0; license(\&advanced_install)}), # gtksignal_connect(new Gtk::Button(_("Uninstall Fonts")), clicked => # sub { ${$central_widget}->destroy(); uninstall() }), # gtksignal_connect(new Gtk::Button(_("Font List")), clicked => # sub { ${$central_widget}->destroy(); create_fontsel()}), # ), # sub interactive_mode { # my $fst_choice_box; # my $fst_choice_box1; # my $pixmap_fst_choice; # $interactive = 1; # my $pixmap; # my $pixmapwid; # my $mask; # my $style; # init Gtk; # $window1 = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel; # $window1->signal_connect (delete_event => sub { Gtk->exit(0) }); # $window1->set_position(1); # $window1->set_title(_("Drakbackup")); # my ($pix_u_map, $pix_u_mask) = gtkcreate_png("/home/seb/draklogo.png"); # my ($pix_l_map, $pix_l_mask) = gtkcreate_png("/home/seb/back_l.png"); # my ($pix_r_map, $pix_r_mask) = gtkcreate_png("/home/seb/back_r.png"); # gtkadd($window1, # gtkpack_(new Gtk::VBox(0,0), # 1, gtkpack_(gtkset_usize(new Gtk::VBox(0,0), 550, 360), # 1, gtkpack_(my $up_box = new Gtk::VBox(0,0), # 1, new Gtk::VBox(0,0), # 1, gtkpack_($fst_choice_box = new Gtk::VBox(0,0), # 0, my $pix_c = new Gtk::Pixmap($pix_u_map, $pix_u_mask), # 0, gtkpack_(new Gtk::HBox(0,1), # 0, my $pix_l = new Gtk::Pixmap($pix_l_map, $pix_l_mask), # 1, gtkpack_(new Gtk::VButtonBox, # 0, gtksignal_connect(new Gtk::Button(_("Wizard")), clicked => sub { # ${$central_widget}->destroy(); wizard() }), # 0, gtksignal_connect(new Gtk::Button(_("Advanced")), clicked => sub { # ${$central_widget}->destroy(); about() }), # ), # ), # 1, my $pix_r = new Gtk::Pixmap($pix_r_map, $pix_r_mask), # ), # ), # 1, gtkpack_(new Gtk::HBox(0,5), # 1, new Gtk::HBox(0,5), # 1, gtkadd(gtkset_layout(new Gtk::HButtonBox, -end), # gtksignal_connect(new Gtk::Button(_("Help")), clicked => sub { # ${$central_widget}->destroy(); help() }), # gtksignal_connect(new Gtk::Button(_("About")), clicked => sub { # ${$central_widget}->destroy(); help() }), # gtksignal_connect(new Gtk::Button(_("Close")), clicked => sub { Gtk->main_quit() }), # ), # ) # ), # ), # ); # $central_widget = \$up_box; # $window1->show_all; # $window1->realize; # $window1->show_all(); # Gtk->main; # Gtk->exit(0); # }