#!/usr/bin/env python # -*- coding: UTF8 -*- # Python module home_backup.py # # Author: Marcel J. Zwiebel # # Simple Python/GTK backup program to backup an user's home directory, # developed for the Dutch Linux desktop distribution Nonux: # # # 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 3.0 of the License, 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: # import os import gtk import time from SimpleGladeApp import SimpleGladeApp homedir = os.environ['HOME'] backupdir = homedir + '/backup' backupfile = backupdir + '/nonux.backup' glade_dir = "" def run_backup(): if os.access( backupdir, os.F_OK ) == 0: os.mkdir( backupdir, 0640 ); if os.access( backupfile, os.F_OK ) == 1: os.remove( backupfile ) os.chdir( homedir ) os.system( '/usr/bin/tar -cjpf /tmp/nonux.backup .' ) if os.access( '/tmp/nonux.backup', os.F_OK ) == 1: os.rename( '/tmp/nonux.backup', backupfile ) class Backup(SimpleGladeApp): def __init__(self, glade_path="home_backup.glade", root="backup", domain=None): glade_path = os.path.join(glade_dir, glade_path) SimpleGladeApp.__init__(self, glade_path, root, domain) #def new(self): def on_button_cancel_clicked(self, widget, *args): self.backup.destroy() def on_button_start_pressed(self, widget, *args): self.text.set_text('\nMaking backup, please wait...\n\n') self.backup.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) def on_button_start_released(self, widget, *args): os.system( 'sleep 2' ) run_backup() self.backup.window.set_cursor(None) if os.access( backupfile, os.F_OK ) == 1: widget.hide() self.text.set_text('Data backup completed.\nSave the file nonux.backup in the\ndirectory backup on an external medium\nlike for example an USB-stick.') else: self.text.set_text('\n\nMaking the backup was unsuccessful!\n\n') def main(): backup = Backup() backup.run() if __name__ == "__main__": main()