view release on metacpan or search on metacpan
123456789101112131415Revision history
for
Perl application BackupAndRestore.
0.011 Sa 21. Jun 10:07:09 CEST 2008
- added some information and reorder and clean up of folders
- added a test
- added -run; so you can now
write
'use Application:BackupAndRestore -run;'
- correcly handling
exit
code 512; The 512
exit
status means tar thinks
it failed
for
some reason. This could be caused by files
with
no
permission.
- added drag an drop support
for
for
exclude file and exclude folder widget
- added remove backup
for
last
backup
- backup dialog is now of type notifiction
- added a Restore Backup Notification
0.010 Jan CEST 2007
- original version; created
bin/BackupAndRestore.glade view on Meta::CPAN
23456789101112131415161718192021222324252627282930313233343536<!DOCTYPE glade-interface SYSTEM
"glade-2.0.dtd"
>
<!--*- mode: xml -*-->
<glade-interface>
<widget class=
"GtkWindow"
id=
"window"
>
<property name=
"border_width"
>6</property>
<property name=
"title"
>Backup
&
; Restore</property>
<property name=
"default_width"
>530</property>
<property name=
"default_height"
>600</property>
<signal name=
"destroy"
handler=
"gtk_main_quit"
/>
<child>
<widget class=
"GtkVBox"
id=
"backup_and_restore_widget"
>
<property name=
"visible"
>True</property>
<property name=
"spacing"
>6</property>
<child>
<widget class=
"GtkFrame"
id=
"frame2"
>
<property name=
"visible"
>True</property>
<property name=
"label_xalign"
>0</property>
<child>
<widget class=
"GtkAlignment"
id=
"alignment2"
>
<property name=
"visible"
>True</property>
<child>
<widget class=
"GtkVBox"
id=
"vbox1"
>
<property name=
"visible"
>True</property>
<child>
<widget class=
"GtkExpander"
id=
"backup_expander"
>
<property name=
"visible"
>True</property>
<property name=
"expanded"
>True</property>
<signal name=
"activate"
handler=
"expander_nop"
/>
<child>
<widget class=
"GtkVBox"
id=
"vbox2"
>
<property name=
"visible"
>True</property>
<property name=
"border_width"
>12</property>
<property name=
"spacing"
>6</property>
<child>
<widget class=
"GtkHBox"
id=
"folder_box"
>
bin/BackupAndRestore.glade view on Meta::CPAN
474849505152535455565758596061626364656667
<property name=
"expand"
>False</property>
<property name=
"fill"
>False</property>
</packing>
</child>
<child>
<widget class=
"GtkFileChooserButton"
id=
"folder"
>
<property name=
"visible"
>True</property>
<property name=
"can_focus"
>True</property>
<property name=
"has_focus"
>True</property>
<property name=
"action"
>GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
<signal name=
"selection_changed"
handler=
"on_backup_folder_changed"
/>
</widget>
<packing>
<property name=
"position"
>1</property>
</packing>
</child>
</widget>
<packing>
<property name=
"expand"
>False</property>
<property name=
"fill"
>False</property>
</packing>
bin/BackupAndRestore.glade view on Meta::CPAN
109110111112113114115116117118119120121122123124125126127128129130131132133134
</widget>
<packing>
<property name=
"position"
>1</property>
</packing>
</child>
<child>
<widget class=
"GtkHBox"
id=
"hbox5"
>
<property name=
"visible"
>True</property>
<property name=
"spacing"
>6</property>
<child>
<widget class=
"GtkButton"
id=
"backup_button"
>
<property name=
"visible"
>True</property>
<property name=
"label"
translatable=
"yes"
>Backup</property>
<property name=
"use_underline"
>True</property>
<property name=
"response_id"
>0</property>
<signal name=
"clicked"
handler=
"on_backup_button_clicked"
/>
</widget>
<packing>
<property name=
"expand"
>False</property>
<property name=
"fill"
>False</property>
</packing>
</child>
<child>
<widget class=
"GtkButton"
id=
"restore_button"
>
<property name=
"visible"
>True</property>
<property name=
"sensitive"
>False</property>
bin/BackupAndRestore.glade view on Meta::CPAN
141142143144145146147148149150151152153154155156157158159160161162163164165166167
<property name=
"expand"
>False</property>
<property name=
"fill"
>False</property>
<property name=
"position"
>1</property>
</packing>
</child>
<child>
<widget class=
"GtkHBox"
id=
"hbox3"
>
<property name=
"visible"
>True</property>
<property name=
"spacing"
>6</property>
<child>
<widget class=
"GtkButton"
id=
"backup_remove_button"
>
<property name=
"visible"
>True</property>
<property name=
"sensitive"
>False</property>
<property name=
"label"
translatable=
"yes"
>gtk-
delete
</property>
<property name=
"use_stock"
>True</property>
<property name=
"response_id"
>0</property>
<signal name=
"clicked"
handler=
"on_backup_remove_button_clicked"
/>
</widget>
<packing>
<property name=
"expand"
>False</property>
<property name=
"fill"
>False</property>
</packing>
</child>
<child>
<widget class=
"GtkLabel"
id=
"label7"
>
<property name=
"visible"
>True</property>
<property name=
"xalign"
>0</property>
bin/BackupAndRestore.glade view on Meta::CPAN
896897898899900901902903904905906907908909910911912913914915916
</widget>
<packing>
<property name=
"top_attach"
>2</property>
<property name=
"bottom_attach"
>3</property>
</packing>
</child>
<child>
<widget class=
"GtkLabel"
id=
"label6"
>
<property name=
"visible"
>True</property>
<property name=
"xalign"
>1</property>
<property name=
"label"
translatable=
"yes"
>Restore backup from:</property>
</widget>
<packing>
<property name=
"x_options"
>GTK_FILL</property>
<property name=
"y_options"
>GTK_FILL</property>
</packing>
</child>
<child>
<widget class=
"GtkLabel"
id=
"label23"
>
<property name=
"visible"
>True</property>
<property name=
"xalign"
>1</property>
bin/BackupAndRestore.glade view on Meta::CPAN
931932933934935936937938939940941942943944945946947948949950951
</widget>
<packing>
<property name=
"left_attach"
>1</property>
<property name=
"right_attach"
>2</property>
<property name=
"top_attach"
>1</property>
<property name=
"bottom_attach"
>2</property>
<property name=
"y_options"
></property>
</packing>
</child>
<child>
<widget class=
"GtkLabel"
id=
"restore_backup_from_label"
>
<property name=
"visible"
>True</property>
<property name=
"events"
>GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name=
"xalign"
>0</property>
<property name=
"label"
translatable=
"yes"
>label</property>
</widget>
<packing>
<property name=
"left_attach"
>1</property>
<property name=
"right_attach"
>2</property>
</packing>
</child>
bin/BackupAndRestore.glade view on Meta::CPAN
996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026
</child>
</widget>
<packing>
<property name=
"expand"
>False</property>
<property name=
"pack_type"
>GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class=
"GtkDialog"
id=
"backup_notification"
>
<property name=
"border_width"
>5</property>
<property name=
"title"
translatable=
"yes"
>Backup in progress</property>
<property name=
"modal"
>True</property>
<property name=
"window_position"
>GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name=
"default_width"
>500</property>
<property name=
"default_height"
>180</property>
<property name=
"type_hint"
>GDK_WINDOW_TYPE_HINT_NOTIFICATION</property>
<property name=
"transient_for"
>window</property>
<property name=
"has_separator"
>False</property>
<signal name=
"delete_event"
handler=
"on_cancel_backup"
/>
<child internal-child=
"vbox"
>
<widget class=
"GtkVBox"
id=
"dialog-vbox3"
>
<property name=
"visible"
>True</property>
<property name=
"events"
>GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
<property name=
"spacing"
>2</property>
<child>
<widget class=
"GtkFrame"
id=
"frame1"
>
<property name=
"visible"
>True</property>
<property name=
"label_xalign"
>0</property>
<child>
bin/BackupAndRestore.glade view on Meta::CPAN
10461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
<property name=
"selectable"
>True</property>
</widget>
<packing>
<property name=
"top_attach"
>2</property>
<property name=
"bottom_attach"
>3</property>
<property name=
"x_options"
>GTK_FILL</property>
<property name=
"y_options"
></property>
</packing>
</child>
<child>
<widget class=
"GtkLabel"
id=
"backup_elapsed_time_label"
>
<property name=
"visible"
>True</property>
<property name=
"xalign"
>0</property>
<property name=
"selectable"
>True</property>
<property name=
"ellipsize"
>PANGO_ELLIPSIZE_START</property>
</widget>
<packing>
<property name=
"left_attach"
>1</property>
<property name=
"right_attach"
>2</property>
<property name=
"top_attach"
>2</property>
<property name=
"bottom_attach"
>3</property>
</packing>
</child>
<child>
<widget class=
"GtkLabel"
id=
"backup_estimated_time_label"
>
<property name=
"visible"
>True</property>
<property name=
"xalign"
>0</property>
<property name=
"selectable"
>True</property>
<property name=
"ellipsize"
>PANGO_ELLIPSIZE_START</property>
</widget>
<packing>
<property name=
"left_attach"
>1</property>
<property name=
"right_attach"
>2</property>
<property name=
"top_attach"
>3</property>
<property name=
"bottom_attach"
>4</property>
bin/BackupAndRestore.glade view on Meta::CPAN
108810891090109110921093109410951096109710981099110011011102110311041105110611071108
<property name=
"selectable"
>True</property>
</widget>
<packing>
<property name=
"top_attach"
>3</property>
<property name=
"bottom_attach"
>4</property>
<property name=
"x_options"
>GTK_FILL</property>
<property name=
"y_options"
></property>
</packing>
</child>
<child>
<widget class=
"GtkLabel"
id=
"backup_file_label"
>
<property name=
"visible"
>True</property>
<property name=
"xalign"
>0</property>
<property name=
"selectable"
>True</property>
<property name=
"ellipsize"
>PANGO_ELLIPSIZE_START</property>
</widget>
<packing>
<property name=
"left_attach"
>1</property>
<property name=
"right_attach"
>2</property>
<property name=
"top_attach"
>4</property>
<property name=
"bottom_attach"
>5</property>
bin/BackupAndRestore.glade view on Meta::CPAN
1142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
<property name=
"xalign"
>1</property>
<property name=
"label"
translatable=
"yes"
>Changed files:</property>
<property name=
"selectable"
>True</property>
</widget>
<packing>
<property name=
"x_options"
>GTK_FILL</property>
<property name=
"y_options"
></property>
</packing>
</child>
<child>
<widget class=
"GtkLabel"
id=
"backup_folders_label"
>
<property name=
"visible"
>True</property>
<property name=
"xalign"
>0</property>
<property name=
"selectable"
>True</property>
<property name=
"ellipsize"
>PANGO_ELLIPSIZE_START</property>
</widget>
<packing>
<property name=
"left_attach"
>1</property>
<property name=
"right_attach"
>2</property>
<property name=
"top_attach"
>1</property>
<property name=
"bottom_attach"
>2</property>
</packing>
</child>
<child>
<widget class=
"GtkLabel"
id=
"backup_changed_files_label"
>
<property name=
"visible"
>True</property>
<property name=
"xalign"
>0</property>
<property name=
"selectable"
>True</property>
<property name=
"ellipsize"
>PANGO_ELLIPSIZE_START</property>
</widget>
<packing>
<property name=
"left_attach"
>1</property>
<property name=
"right_attach"
>2</property>
</packing>
</child>
</widget>
<packing>
<property name=
"expand"
>False</property>
</packing>
</child>
<child>
<widget class=
"GtkProgressBar"
id=
"backup_progressbar"
>
<property name=
"visible"
>True</property>
<property name=
"pulse_step"
>0</property>
</widget>
<packing>
<property name=
"position"
>1</property>
</packing>
</child>
</widget>
</child>
</widget>
bin/BackupAndRestore.glade view on Meta::CPAN
1214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259
<property name=
"layout_style"
>GTK_BUTTONBOX_END</property>
<child>
<placeholder/>
</child>
<child>
<widget class=
"GtkButton"
id=
"button5"
>
<property name=
"visible"
>True</property>
<property name=
"label"
translatable=
"yes"
>gtk-cancel</property>
<property name=
"use_stock"
>True</property>
<property name=
"response_id"
>0</property>
<signal name=
"clicked"
handler=
"on_cancel_backup"
/>
</widget>
<packing>
<property name=
"position"
>1</property>
</packing>
</child>
</widget>
<packing>
<property name=
"expand"
>False</property>
<property name=
"pack_type"
>GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class=
"GtkDialog"
id=
"remove_dialog"
>
<property name=
"border_width"
>5</property>
<property name=
"title"
translatable=
"yes"
>Remove backup</property>
<property name=
"modal"
>True</property>
<property name=
"window_position"
>GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name=
"default_width"
>390</property>
<property name=
"default_height"
>100</property>
<property name=
"type_hint"
>GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name=
"transient_for"
>window</property>
<property name=
"has_separator"
>False</property>
<signal name=
"delete_event"
handler=
"on_backup_remove_dialog_cancel"
/>
<child internal-child=
"vbox"
>
<widget class=
"GtkVBox"
id=
"dialog-vbox4"
>
<property name=
"visible"
>True</property>
<property name=
"events"
>GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
<property name=
"spacing"
>2</property>
<child>
<widget class=
"GtkFrame"
id=
"frame3"
>
<property name=
"visible"
>True</property>
<property name=
"label_xalign"
>0</property>
<child>
bin/BackupAndRestore.glade view on Meta::CPAN
12611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301
<property name=
"visible"
>True</property>
<property name=
"border_width"
>12</property>
<child>
<widget class=
"GtkHBox"
id=
"hbox4"
>
<property name=
"visible"
>True</property>
<child>
<widget class=
"GtkLabel"
id=
"label27"
>
<property name=
"visible"
>True</property>
<property name=
"xalign"
>1</property>
<property name=
"xpad"
>6</property>
<property name=
"label"
translatable=
"yes"
>Remove backup from:</property>
</widget>
</child>
<child>
<widget class=
"GtkLabel"
id=
"backup_remove_from_label"
>
<property name=
"visible"
>True</property>
<property name=
"xalign"
>0</property>
<property name=
"label"
translatable=
"yes"
>label</property>
</widget>
<packing>
<property name=
"position"
>1</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class=
"GtkLabel"
id=
"label28"
>
<property name=
"visible"
>True</property>
<property name=
"label"
translatable=
"yes"
>
<
;b
>
;Remove backup
<
;/b
>
;</property>
<property name=
"use_markup"
>True</property>
</widget>
<packing>
<property name=
"type"
>label_item</property>
</packing>
</child>
</widget>
<packing>
<property name=
"position"
>1</property>
</packing>
bin/BackupAndRestore.glade view on Meta::CPAN
130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333<widget class=
"GtkHButtonBox"
id=
"dialog-action_area4"
>
<property name=
"visible"
>True</property>
<property name=
"events"
>GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
<property name=
"layout_style"
>GTK_BUTTONBOX_END</property>
<child>
<widget class=
"GtkButton"
id=
"button7"
>
<property name=
"visible"
>True</property>
<property name=
"label"
translatable=
"yes"
>gtk-ok</property>
<property name=
"use_stock"
>True</property>
<property name=
"response_id"
>0</property>
<signal name=
"clicked"
handler=
"on_backup_remove_dialog_ok"
/>
</widget>
</child>
<child>
<widget class=
"GtkButton"
id=
"button6"
>
<property name=
"visible"
>True</property>
<property name=
"label"
translatable=
"yes"
>gtk-cancel</property>
<property name=
"use_stock"
>True</property>
<property name=
"response_id"
>0</property>
<signal name=
"clicked"
handler=
"on_backup_remove_dialog_cancel"
/>
</widget>
<packing>
<property name=
"position"
>1</property>
</packing>
</child>
</widget>
<packing>
<property name=
"expand"
>False</property>
<property name=
"pack_type"
>GTK_PACK_END</property>
</packing>
bin/BackupAndRestore.glade view on Meta::CPAN
145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480
<property name=
"top_attach"
>1</property>
<property name=
"bottom_attach"
>2</property>
<property name=
"x_options"
>GTK_FILL</property>
<property name=
"y_options"
></property>
</packing>
</child>
<child>
<widget class=
"GtkLabel"
id=
"label33"
>
<property name=
"visible"
>True</property>
<property name=
"xalign"
>1</property>
<property name=
"label"
translatable=
"yes"
>Process backup:</property>
<property name=
"selectable"
>True</property>
</widget>
<packing>
<property name=
"x_options"
>GTK_FILL</property>
<property name=
"y_options"
></property>
</packing>
</child>
<child>
<widget class=
"GtkLabel"
id=
"restore_process_backup_label"
>
<property name=
"visible"
>True</property>
<property name=
"xalign"
>0</property>
<property name=
"selectable"
>True</property>
<property name=
"ellipsize"
>PANGO_ELLIPSIZE_START</property>
</widget>
<packing>
<property name=
"left_attach"
>1</property>
<property name=
"right_attach"
>2</property>
</packing>
</child>
lib/Applications/BackupAndRestore.pm view on Meta::CPAN
4567891011121314151617181920212223242526272829303132our
$VERSION
= 0.021;
our
$DEBUG
= 1;
=head1 NAME
Applications::BackupAndRestore - a linux frontend for tar
=head1 DESCRIPTION
BackupAndRestore is a backup utility for making incremental backups by using GNU Tar.
Core features:
=over
=item *
Incremental backup with quick and easy restoration of files
=item *
Handels different backup locations
=item *
Full support for excluding files and folders and even file patterns (shell regex)
=item *
Handels different store locations
=item *
Log with all relevant information
lib/Applications/BackupAndRestore.pm view on Meta::CPAN
525354555657585960616263646566676869707172737475767778=begin html
<img src="BackupAndRestore/pod/BackupAndRestore.png"><br>
=end html
=head1
To start up Backup & Restore from a terminal window, type B<BackupAndRestore> and then press C<Enter>.
Backup & Restore has a List View where you see every single backup with time, date, changed files and the exact space required on your harddrive.
Above the list view there is a File Chooser Button where you can select a folder to backup. Position the cursor over File Chooser Button and press the right mouse button. A pop-up menu appears. Choose a folder from the pop-up menu. Drag a folder ico...
Right hand to the File Chooser Button there is a Recycle Button. The recycle button keeps a list of folders you have saved. For example, place the cursor over the recycle button on a Backup & Restore window; then press the left mouse button to see a ...
Below the list view there is a backup button.
=head2 Backup In Progress Notification
The Backup In Progress Notification is illustrated in Figure 1-2.
=head3 Figure 1-2. Backup In Progress Notification
=begin html
<img src="BackupAndRestore/pod/BackupInProgressNotification.png"><br>
lib/Applications/BackupAndRestore.pm view on Meta::CPAN
378379380381382383384385386387388389390391392393394395396397398#configure;
$this
->restore_extract_modifiction_time->set_active(
defined
$this
->gconf(
"restore-extract-modification-time"
)
?
$this
->gconf(
"restore-extract-modification-time"
)
: 1
);
$this
->restore_folder->set_current_folder(
$this
->gconf(
"restore-folder"
) ||
$ENV
{HOME} );
$this
->store_folder->set_current_folder(
$this
->gconf(
"store-folder"
) ||
$ENV
{HOME} );
$this
->store_folder_name->set_text(
$this
->gconf(
"store-folder-name"
) ||
"Backup"
);
$this
->folder->set_current_folder(
$this
->gconf(
"current-backup-folder"
) ||
$ENV
{HOME} );
$this
->configure_expander;
$this
->build_tree;
$this
->log_init;
$this
->log_add_text(
"*** $ApplicationName\n"
,
"Version: $VERSION\n"
,
"\n"
, );
$this
->log_add_text(
"*** "
,
$this
->get_tar_version );
$this
->{init} = FALSE;
lib/Applications/BackupAndRestore.pm view on Meta::CPAN
562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
$tree_column
->pack_start(
$renderer
, FALSE );
$tree_column
->add_attribute(
$renderer
,
text
=> COL_PATH );
#$tree_column->set_sort_column_id(COL_PATH);
#add $tree_column to the treeviewGtk2::CellRenderer
$tree_view
->append_column(
$tree_column
);
}
#backup
#
sub
on_backup_folder_changed {
my
(
$this
) =
@_
;
return
unless
$this
->folder->get_filename;
return
if
abs_path(
$this
->folder->get_filename ) eq
$this
->gconf(
"current-backup-folder"
);
printf
"on_backup_folder_changed %s\n"
, abs_path
$this
->folder->get_filename
if
$DEBUG
> 0;
$this
->gconf(
"current-backup-folder"
, abs_path
$this
->folder->get_filename );
$this
->fill_tree;
return
;
}
sub
on_folder_recycle_button {
my
(
$this
) =
@_
;
return
unless
$this
->{folder_recycle_button}->get_filename;
return
if
$this
->folder->get_filename eq abs_path(
$this
->{folder_recycle_button}->get_filename );
lib/Applications/BackupAndRestore.pm view on Meta::CPAN
614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652my
$folder
=
$this
->get_store_folder;
printf
"fill_tree %s\n"
,
$folder
if
$DEBUG
> 0;
my
$tree_store
= Gtk2::TreeStore->new(
@ColumnTypes
);
if
( -e
$folder
) {
my
(
$day_iter
,
$day
,
$day_folder_size
,
$day_folder_real_size
,
$day_folder_files
) = (
undef
,
""
, 0, 0, 0 );
my
$current_dat
=
"$folder/$CurrentDat"
;
my
$date_of_last_backup
=
$this
->fetch_restore_date(
$folder
);
#printf "%s\n", $date_of_last_backup;
my
@filenames
=
reverse
grep
{ m/\.tar\.bz2$/ } get_files(
$folder
);
foreach
my
$filename
(
@filenames
) {
# get basename
my
$basename
= basename(
$filename
,
".tar.bz2"
);
# calculate size
my
$tardat
=
"$folder/$basename.dat.bz2"
;
my
$size
= ( -s
$filename
) + ( -s
$tardat
);
$size
+= -s
$current_dat
unless
$day
;
################################################################
my
$infofile
=
"$folder/$basename.info.txt"
;
my
$info
=
$this
->get_backup_info(
$filename
,
$infofile
);
################################################################
# append day folder
my
(
$date
,
$time
) =
split
/ /o,
$basename
;
if
(
$date
ne
$day
) {
$tree_store
->set(
$day_iter
,
(
COL_SIZE,
$day_folder_size
, COL_REAL_SIZE,
$day_folder_real_size
, COL_HSIZE,
(
sprintf
"%sB (%sB)"
, format_bytes(
$day_folder_size
), format_bytes(
$day_folder_real_size
) ),
lib/Applications/BackupAndRestore.pm view on Meta::CPAN
687688689690691692693694695696697698699700701702703704705706707708709710711712713714
format_date(
$date
),
COL_TIME,
$time
, COL_NAME,
$time
, COL_SIZE,
$size
,
COL_HSIZE,
(
sprintf
"%sB (%sB)"
, format_bytes(
$size
), format_bytes(
$info
->{size} ) ),
COL_FILES,
scalar
@{
$info
->{files} },
COL_LABEL,
__(
"$info->{label}"
)
. (
"$info->{label}"
?
", "
:
""
)
. (
$date_of_last_backup
eq
$basename
? __(
"Last backup."
)
:
""
),
COL_PATH,
$filename
,
COL_LAST_BACKUP,
$date_of_last_backup
eq
$basename
,
COL_WEIGHT,
800,
)
);
}
# append last day folder
$tree_store
->set(
$day_iter
,
(
lib/Applications/BackupAndRestore.pm view on Meta::CPAN
721722723724725726727728729730731732733734735736737738739740
$this
->size_all->set_text( format_bytes( folder_size(
$folder
) ) );
#this will create a treeview, specify $tree_store as its model
$this
->tree_view->set_model(
$tree_store
);
$this
->exclude_configure;
#$this->window->set_sensitive(TRUE);
}
sub
get_backup_info {
my
(
$this
,
$filename
,
$infoname
) =
@_
;
tie
my
%info
,
'Tie::DataDumper'
,
$infoname
or
warn
"Problem tying %info: $!"
;
$info
{folders} = 0
unless
exists
$info
{folders};
$info
{files} = []
unless
exists
$info
{files};
$info
{label} =
''
unless
exists
$info
{label};
$info
{size} = 0
unless
exists
$info
{size};
lib/Applications/BackupAndRestore.pm view on Meta::CPAN
785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
if
(
$this
->{tree_view_2button_press} )
# double click
{
my
$path
=
$this
->tree_view->get_model->get(
$selected
, COL_PATH );
printf
"*** %s\n"
,
$path
if
$DEBUG
> 3;
system
$TarOpenCmd
,
$path
;
}
else
{
my
$last_backup
=
$this
->tree_view->get_model->get(
$selected
, COL_LAST_BACKUP );
printf
"*** %s\n"
,
$last_backup
? 1 : 0
if
$DEBUG
> 3;
if
(
$last_backup
) {
$this
->backup_remove_button->set_sensitive(TRUE);
}
else
{
$this
->backup_remove_button->set_sensitive(FALSE);
}
}
}
return
;
}
#backup
#
sub
on_backup_button_clicked {
my
(
$this
) =
@_
;
"on_backup_button_clicked $this\n"
if
$DEBUG
> 3;
$this
->window->set_sensitive(FALSE);
$this
->backup_changed_files_label->set_text(0);
$this
->backup_folders_label->set_text(0);
$this
->backup_elapsed_time_label->set_text(
sprintf
"%s"
, strtime(0) );
$this
->backup_estimated_time_label->set_text(
sprintf
"%s / %s"
,
map
{ strtime(0) } ( 0, 0 ) );
$this
->backup_file_label->set_text(
""
);
$this
->backup_progress(0);
$this
->backup_notification->present;
$this
->backup_folder;
$this
->{folder_recycle_button}->set_uri(
$this
->folder->get_uri );
$this
->fill_tree;
$this
->backup_notification->hide;
$this
->window->set_sensitive(TRUE);
return
;
}
sub
rmdir_p {
my
(
$folder
) =
@_
;
while
(
rmdir
$folder
) {
$folder
= dirname
$folder
;
}
return
;
}
sub
backup_folder {
my
(
$this
) =
@_
;
#$this->{backup_folder} = TRUE;
my
$date
= strftime(
"%F %X"
,
localtime
);
$this
->log_add_text(
sprintf
"\n%s\n"
,
"*"
x 42 );
$this
->log_add_text(
sprintf
__(
"%s Starting backup . . .\n"
),
$date
);
$this
->backup_progress(0);
$this
->backup_notification->{startTime} =
time
;
my
$folder
= abs_path
$this
->folder->get_filename;
my
$store
=
$this
->get_store_folder;
my
$mainstore
=
$this
->get_main_store_folder;
my
$current_dat
=
"$store/$CurrentDat"
;
my
$process_dat
=
"$store/$ProcessDat"
;
my
$archive
=
"$store/$date.tar.bz2"
;
my
$tardat
=
"$store/$date.dat.bz2"
;
my
$excludes
=
"$store/$ExcludesFile"
;
my
$first
= -e
$excludes
;
$this
->{cleanup} =
sub
{
"cleanup backup @_\n"
if
$DEBUG
> 3;
unlink
$tardat
;
unlink
$process_dat
;
unlink
$archive
;
unless
( -s
$current_dat
) {
unlink
$current_dat
;
unlink
$excludes
;
rmdir_p
$store
;
}
if
(
@_
) {
$this
->gtk_main_quit;
lib/Applications/BackupAndRestore.pm view on Meta::CPAN
910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971my
$size
= 1;
my
$files
= {};
my
$total_size
= 1;
my
$folders
= 0;
my
$utf8
= Unicode::UTF8simple->new;
while
(<TAR>) {
$_
if
$DEBUG
> 3;
#last unless $this->{backup_folder};
chomp
;
$_
=
$utf8
->fromUTF8(
"iso-8859-1"
,
$_
);
if
(s|^\./||o) {
my
$path
=
"$folder/$_"
;
if
( -d
$path
) {
$this
->backup_folders_label->set_text( ++
$folders
);
Gtk2->main_iteration
while
Gtk2->events_pending;
}
else
{
unless
(
exists
$files
->{
$path
} ) {
$total_size
+=
$files
->{
$path
} = ( -s
$path
) || 0;
$this
->backup_changed_files_label->set_text(
sprintf
"%d [%sB]"
,
scalar
keys
%$files
,
format_bytes(
$total_size
) );
}
$files
->{
$path
} = 0
unless
defined
$files
->{
$path
};
# wegen: -s link = 0
my
@times
=
map
{ strtime(
$_
) } estimated_time(
$this
->backup_notification->{startTime},
$size
,
$total_size
);
$this
->backup_elapsed_time_label->set_text(
sprintf
"%s"
,
$times
[0] );
$this
->backup_estimated_time_label->set_text(
sprintf
"%s / %s"
,
@times
[ 1, 2 ] );
$this
->backup_file_label->set_text(
sprintf
"%s [%sB]"
,
$path
, format_bytes(
$files
->{
$path
} ) );
$this
->backup_progress(
$size
/
$total_size
);
$size
+=
$files
->{
$path
};
}
}
elsif
( m|^tar: \./(.*?): Directory is new$|o
|| m|^tar: \./(.*?): Directory
has
been renamed from.*$|o )
{
#print "$1\n" if $DEBUG > 3;
$files
->{
$_
} = -s
$_
foreach
get_files(
"$folder/$1"
);
$total_size
+= folder_size(
"$folder/$1"
);
$this
->backup_changed_files_label->set_text(
sprintf
"%d [%sB]"
,
scalar
keys
%$files
, format_bytes(
$total_size
) );
Gtk2->main_iteration
while
Gtk2->events_pending;
}
elsif
(/^(tar: ).*?(Warning:)/o) {
"$_\n"
if
$DEBUG
> 3;
$this
->log_add_text(
$_
,
"\n"
);
}
elsif
(/^(tar: )?(Terminated|Killed|Hangup)$/o) {
"$_\n"
if
$DEBUG
> 3;
$this
->log_add_text(
$_
,
"\n"
);
}
lib/Applications/BackupAndRestore.pm view on Meta::CPAN
99399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
my
$retval
=
system
qq{ nice --adjustment=17 \\
bzip2 -c9 "$process_dat" > "$tardat" \\
}
;
printf
"bzip2 returned %s\n"
,
$retval
if
$DEBUG
> 3;
$SIG
{
$_
} =
'IGNORE'
foreach
@SIGS
;
system
"cp"
,
$process_dat
,
$current_dat
;
unlink
$process_dat
;
#store date of current backup
$this
->store_restore_date(
$archive
);
#store size
my
$infofile
=
"$store/$date.info.txt"
;
my
$info
=
$this
->get_backup_info(
$archive
,
$infofile
);
$info
->{label} =
"First Backup"
unless
$first
;
$info
->{folders} =
$folders
;
$info
->{files} = [
keys
%$files
];
$info
->{size} =
$total_size
;
tied
(
%$info
)->save;
}
#$this->{backup_folder} = FALSE;
$this
->{tarpid} = 0;
if
(
$this
->backup_notification->{startTime} ) {
$this
->log_add_text(
sprintf
__(
"Changed files: %d\n"
),
scalar
keys
%$files
);
$this
->log_add_text(
sprintf
__(
"Folders: %d\n"
),
$folders
);
$this
->log_add_text(
sprintf
__(
"Total size: %s\n"
), format_bytes(
$total_size
) );
$this
->log_add_text(
sprintf
__(
"Total time: %s\n"
),
strtime(
localtime
(
time
-
$this
->backup_notification->{startTime} ) ) );
}
$this
->log_add_text(
sprintf
__(
"%s Backup done.\n"
), strftime(
"%F %X"
,
localtime
) )
if
$this
->backup_notification->{startTime};
$SIG
{
$_
} =
sub
{
$this
->gtk_main_quit }
foreach
@SIGS
;
}
sub
backup_progress {
my
(
$this
,
$fraction
) =
@_
;
$this
->backup_progressbar->set_fraction(
$fraction
);
$this
->backup_progressbar->set_text(
sprintf
"%.2f %%"
,
$fraction
* 100 );
#$this->backup_notification->set_title( sprintf "Backup in progress %.2f %%", $fraction * 100 );
Gtk2->main_iteration
while
Gtk2->events_pending;
return
;
}
sub
on_cancel_backup {
my
(
$this
) =
@_
;
printf
"on_cancel_backup %s\n"
,
$this
->{tarpid}
if
$DEBUG
> 3;
system
"pkill"
,
"-P"
,
$this
->{tarpid};
$this
->backup_notification->{startTime} = 0;
$this
->backup_progressbar->set_fraction(1);
$this
->backup_progressbar->set_text( __
"Canceling Backup ..."
);
#$this->{backup_folder} = FALSE;
$this
->log_add_text(
sprintf
__(
"%s Backup canceled.\n"
), strftime(
"%F %X"
,
localtime
) );
return
1;
}
#exclude
#
sub
exclude_configure {
my
(
$this
) =
@_
;
lib/Applications/BackupAndRestore.pm view on Meta::CPAN
12681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
return
;
}
sub
on_restore_button_clicked {
my
(
$this
) =
@_
;
"on_restore_button_clicked $this\n"
if
$DEBUG
> 3;
my
$selected
=
$this
->tree_view->get_selection->get_selected;
my
(
$hdate
,
$time
) =
$this
->tree_view->get_model->get(
$selected
, COL_HDATE, COL_TIME );
$this
->restore_backup_from_label->set_text(
"$hdate $time"
);
$this
->window->set_sensitive(FALSE);
$this
->restore_dialog->show;
return
;
}
sub
on_restore_dialog_cancel {
my
(
$this
,
$widget
) =
@_
;
"on_restore_folder_dialog_cancel $this\n"
if
$DEBUG
> 3;
$this
->restore_dialog->hide;
$this
->window->set_sensitive(TRUE);
return
1;
}
sub
on_restore_dialog_ok {
my
(
$this
,
$widget
) =
@_
;
$this
->restore_dialog->hide;
$this
->restore_notification->show;
$this
->restore_backup;
$this
->fill_tree;
$this
->restore_notification->hide;
$this
->window->set_sensitive(TRUE);
return
;
}
sub
restore_backup {
my
(
$this
) =
@_
;
my
$restore_to_folder
= abs_path
$this
->restore_folder->get_filename;
my
@files
=
$this
->get_files_to_restore;
$this
->log_add_text(
sprintf
"\n%s\n"
,
"*"
x 42 );
$this
->log_add_text(
sprintf
__(
"%s Starting restore . . .\n"
), strftime(
"%F %X"
,
localtime
) );
$this
->restore_progress(0);
$this
->restore_notification->{startTime} =
time
;
my
$store
=
$this
->get_store_folder;
my
$utf8
= Unicode::UTF8simple->new;
my
$backup
= 0;
my
$counter
= 0;
my
$numFiles
= 0;
my
$size
= 0;
my
$elapsedSize
= 0;
my
$totalSize
= 0;
foreach
my
$filename
(
@files
) {
my
$infofile
=
"$store/"
. basename(
$filename
,
".tar.bz2"
) .
".info.txt"
;
my
$info
=
$this
->get_backup_info(
$filename
,
$infofile
);
$numFiles
+= @{
$info
->{files} };
$totalSize
+=
$info
->{size};
$this
->log_add_text(
sprintf
"%s %d\n"
,
$infofile
,
$info
->{size} );
}
$this
->log_add_text(
sprintf
"total size %d\n"
,
$totalSize
);
printf
"***restore_backup to folder: %s %d\n"
,
$restore_to_folder
,
$totalSize
if
$DEBUG
> 3;
foreach
my
$filename
(
@files
) {
printf
"file: %s\n"
,
$filename
if
$DEBUG
> 3;
##########################################################################
my
$infofile
=
"$store/"
. basename(
$filename
,
".tar.bz2"
) .
".info.txt"
;
my
$info
=
$this
->get_backup_info(
$filename
,
$infofile
);
##########################################################################
$this
->log_add_text(
sprintf
__(
"restoring backup from %s\n"
), basename(
$filename
,
".tar.bz2"
) );
$this
->restore_process_backup_label->set_text(
sprintf
__(
"%d / %d"
), ++
$backup
,
scalar
@files
);
Gtk2->main_iteration
while
Gtk2->events_pending;
my
$touch
=
$this
->restore_extract_modifiction_time->get_active
?
""
:
"--touch"
;
my
$cmd
= qq{ env LANG=en_GB.utf8 nice --adjustment=17 \\
env LANG=en_GB.utf8 tar --extract \\
--verbose \\
lib/Applications/BackupAndRestore.pm view on Meta::CPAN
145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528
$this
->log_add_text(
sprintf
__(
"%s Restore canceled.\n"
), strftime(
"%F %X"
,
localtime
) );
return
1;
}
sub
restore_progress {
my
(
$this
,
$fraction
) =
@_
;
$this
->restore_progressbar->set_fraction(
$fraction
);
$this
->restore_progressbar->set_text(
sprintf
"%.2f %%"
,
$fraction
* 100 );
#$this->backup_notification->set_title( sprintf "Backup in progress %.2f %%", $fraction * 100 );
return
;
}
# remove backup
#
sub
on_backup_remove_button_clicked {
my
(
$this
) =
@_
;
"on_backup_remove_button_clicked $this\n"
if
$DEBUG
> 3;
my
$selected
=
$this
->tree_view->get_selection->get_selected;
my
(
$hdate
,
$time
) =
$this
->tree_view->get_model->get(
$selected
, COL_HDATE, COL_TIME );
$this
->backup_remove_from_label->set_text(
"$hdate $time"
);
$this
->window->set_sensitive(FALSE);
$this
->remove_dialog->show;
return
;
}
sub
on_backup_remove_dialog_cancel {
my
(
$this
,
$widget
) =
@_
;
"on_restore_folder_dialog_cancel $this\n"
if
$DEBUG
> 3;
$this
->remove_dialog->hide;
$this
->window->set_sensitive(TRUE);
return
1;
}
sub
on_backup_remove_dialog_ok {
my
(
$this
,
$widget
) =
@_
;
$this
->remove_dialog->hide;
$this
->remove_backup;
$this
->fill_tree;
$this
->window->set_sensitive(TRUE);
$this
->backup_remove_button(FALSE);
return
;
}
sub
remove_backup {
my
(
$this
) =
@_
;
my
$restore_to_folder
= abs_path
$this
->restore_folder->get_filename;
my
@files
=
$this
->get_files_to_restore;
my
$selected
=
$this
->tree_view->get_selection->get_selected;
my
(
$hdate
,
$date
,
$time
,
$file
) =
$this
->tree_view->get_model->get(
$selected
, COL_HDATE, COL_DATE, COL_TIME, COL_PATH );
my
$folder
= dirname
$file
;
my
$store
=
$this
->get_store_folder;
$this
->log_add_text(
sprintf
"\n%s\n"
,
"*"
x 42 );
$this
->log_add_text(
sprintf
__(
"%s removing backup from %s %s\n"
), strftime(
"%F %X"
,
localtime
),
$hdate
,
$time
);
{
my
$archive
=
"$store/$date $time.tar.bz2"
;
my
$tardat
=
"$store/$date $time.dat.bz2"
;
my
$infofile
=
"$folder/$date $time.info.txt"
;
"$archive\n"
;
"$tardat\n"
;
"$infofile\n"
;
lib/Applications/BackupAndRestore/Helper.pm view on Meta::CPAN
101112131415161718192021222324252627282930
sum
format_date
get_files
get_all_sub_folders
folder_size
strtime
estimated_time
);
#use Locale::TextDomain ('backup-and-restore');
sub
__ {
shift
@_
}
=functions
print sum(1,2,3); # 6
print format_date('2007-01-30'); # Heute, Gestern, Montag ..
print get_files('/'); # ('a.txt', 'bin') nicht rekursiv
print folder_size('/'); # 2345, (in Bytes) nicht rekursiv
print strtime(1234); # 00:11:08
my ($elapsed_time, $estimated_time, $total_time) =