Télécharger des logiciels Windows, Mac, Linux, Palm, Pocket PC, Mobile, Jeux, scripts PHP, script ASP, scripts CGI, scripts PERL. Télécharger des cours, des wallpapers, des curseurs, des gifs animés, des fonds d'écran, fonds d'écrans, des textures, des icônes, des dessins. Gratuiciels, freeware, shareware, démonstration, gratuit.
Faites le plein de téléchargements !
Télécharger des logiciels pour WindowsTélécharger des logiciels pour MacintoshTélécharger des logiciels pour LinuxTélécharger des logiciels pour PalmTélécharger des logiciels pour Pocket PCTélécharger sonnerie, jeux java, logo, image, vidéo et musique pour téléphone mobileTélécharger fond d'écran, wallpaper, gif animé, icône, curseur, dessin, photo, image et smiley gratuitTélécharger scripts PHP, ASP, ASP.NET, CGI-PERL, Javascript, Python, Flash, C, C++, DHTML, XML et CFM gratuitTélécharger cours gratuit et tutoriauxForumsShopping, comparateur de prix et achat en ligne
 
Télécharger le script Directory backup-samba - Toocharger.com.
l►► Télécharger Directory backup-samba v1.1. Ce script python crée un backup (copie de sauvegarde) en un zip daté à partir d'un dossier, puis l'envoie sur un partage de fichiers SMB (samba) d'une entité fictive appelée EM-SERIOUS.ORG. Script directory backup-samba.
Scripts > Python > Réseau > Divers > Directory backup-samba

Scripts PHP, ASP, Flash, CGI-PERL, Javascript, ASP.NET, Python, C, C++, DHTML, XML et CFM

SCRIPT DIRECTORY BACKUP-SAMBA v 1.1

 

Script  Directory backup-samba
Agrandir Cliquez pour agrandir
Ce script python crée un backup (copie de sauvegarde) en un zip daté à partir d'un dossier, puis l'envoie sur un partage de fichiers SMB (samba) d'une entité fictive appelée EM-SERIOUS.ORG. Si l'envoi sur le réseau est impossible, le zip est alors stocké dans le même dossier que le script, et l'utilisateur en est notifié. Une interface graphique simple guide l'utilisateur à travers les étapes de la création du backup.

Télécharger

CODE SOURCE (imprimer) :
  1. #!/bin/env python
  2.  
  3. # Directory backup on SMB (samba) share via VPN or locally for EM-SERIOUS.ORG
  4.  
  5. # Author : Stephen LARROQUE <lrq3000@gmail.com>
  6.  
  7. # DESCRIPTION : Zip-date the specified directory by user and send it to a remote (via vpn) or local filesharing server to the fictious servers of the fictious enterprise called EM-SERIOUS.ORG by using SMB shares. If no connection could be made, the backup is stored in the same folder as the script and user is notified.
  8.  
  9. # License : LGPL v3 -> for complete instructions see http://www.gnu.org/licenses/lgpl-3.0.html
  10.  
  11. import smb, nmb, getpass, os, zipfile, time;
  12.  
  13. import easygui as gui
  14. import sys
  15.  
  16. #######################################################
  17. ################### FUNCTIONS ########################
  18. #######################################################
  19. def makeArchive(fileList, archive):
  20. """
  21. 'fileList' is a list of file names - full path each name
  22. 'archive' is the file name for the archive with a full path
  23. """
  24. try:
  25. a = zipfile.ZipFile(archive, 'w', zipfile.ZIP_DEFLATED)
  26. for f in fileList:
  27. print "archiving file %s" % (f)
  28. a.write(f)
  29. a.close()
  30. return True
  31. except: return False
  32.  
  33.  
  34. def dirEntries(dir_name, subdir, *args):
  35. '''Return a list of file names found in directory 'dir_name'
  36. If 'subdir' is True, recursively access subdirectories under 'dir_name'.
  37. Additional arguments, if any, are file extensions to match filenames. Matched
  38. file names are added to the list.
  39. If there are no additional arguments, all files found in the directory are
  40. added to the list.
  41. Example usage: fileList = dirEntries(r'H:\TEMP', False, 'txt', 'py')
  42. Only files with 'txt' and 'py' extensions will be added to the list.
  43. Example usage: fileList = dirEntries(r'H:\TEMP', True)
  44. All files and all the files in subdirectories under H:\TEMP will be added
  45. to the list.
  46. '''
  47. fileList = []
  48. for file in os.listdir(dir_name):
  49. dirfile = os.path.join(dir_name, file)
  50. if os.path.isfile(dirfile):
  51. if not args:
  52. fileList.append(dirfile)
  53. else:
  54. if os.path.splitext(dirfile)[1][1:] in args:
  55. fileList.append(dirfile)
  56. # recursively access file names in subdirectories
  57. elif os.path.isdir(dirfile) and subdir:
  58. print "Accessing directory:", dirfile
  59. fileList.extend(dirEntries(dirfile, subdir, *args))
  60. return fileList
  61.  
  62.  
  63.  
  64. def SMBSEND (servername, serverip, login, password, group, filepath, zipname):
  65. print 'Connecting to server ' + serverip + ' with name ' + servername;
  66. fileshare = smb.SMB(servername, serverip, my_name = "ClientBackup", host_type = nmb.TYPE_SERVER, sess_port = nmb.NETBIOS_SESSION_PORT);
  67. print 'Success !';
  68.  
  69. if (login == ''):
  70. if (fileshare.is_login_required()) :
  71. print "Login is required to connect to this SMB sharing server !";
  72. sys.exit();
  73. else :
  74. print 'Identification...';
  75. fileshare.login(login, password)
  76. print 'Success !';
  77.  
  78. print 'Connecting to domain ' + fileshare.get_server_os() + ' lanname ' + fileshare.get_server_lanman() + ' running OS ' + fileshare.get_server_os();
  79. #print 'Listing shares...'
  80. #print fileshare.list_shared();
  81. print 'Checking path exists...';
  82. if ( fileshare.list_path( group, os.path.join(filepath, '\*') ) ):
  83. print "Dir exists !";
  84. print 'Succeed';
  85.  
  86. print 'Sending file to server...';
  87. src_path = zipname;
  88. dest_service = group;
  89. dest_path = os.path.join(filepath, zipname);
  90. fh = open(src_path, 'rb');
  91. fileshare.stor_file(dest_service, dest_path, fh.read);
  92. fh.close();
  93. print 'Success !';
  94.  
  95.  
  96.  
  97. def VPNCONNECT ():
  98. print os.name
  99. if (os.name == "nt"):
  100. import vpnwin.py;
  101. Connect("vpn.em-serious.org");
  102. elif (os.name == "posix"):
  103. import vpnlin.py;
  104. connection = "EMSERIOUSVPN";
  105. conn.up();
  106. else:
  107. gui.msgbox('Your OS is not supported for the automatic VPN setup, you have to configure it manually before using this script ! If you already set a VPN tunnel, make sure it is activated.', 'ERROR : OS not supported for automatic VPN setup', image="error_button.gif");
  108.  
  109.  
  110.  
  111. #######################################################
  112. ####################### MAIN ##########################
  113. #######################################################
  114. if __name__ == '__main__':
  115.  
  116. # Ask user his login, password and group
  117. msg = "Enter your login informations";
  118. title = "Backup files to sharing server";
  119. fieldNames = ["Group","Login","Password"];
  120. fieldValues = []; # we start with blanks for the values
  121. fieldValues = gui.multpasswordbox(msg, title, fieldNames);
  122. group = fieldValues[0];
  123. login = fieldValues[1];
  124. passwd = fieldValues[2];
  125.  
  126. # Ask user what file to choose
  127. folder = gui.diropenbox(msg="Please select the folder that you want to include in the backup", title="Select a folder to backup");
  128. # Get current date and time (we'll use the date and time to name the zip)
  129. currentdatetime = time.strftime('%y-%m-%d_%H-%M-%S',time.localtime());
  130.  
  131. # Zip it !
  132. zipname = currentdatetime + r'.zip'; # The temporary zip will be placed in the same folder as the script
  133. makeArchive(dirEntries(folder, True), zipname);
  134. # Zipping done !
  135. # Sending the backup
  136. try :
  137. # Trying to send the backup locally (if the VPN is already set and activated, it will work too)
  138. SMBSEND('PARIS2', 'mainserver.bonyridup.com', login, passwd, group, os.path.join('Backup', login), zipname);
  139. gui.msgbox("Backup successfully sent to the local SMB sharing server !", title="Backup done !", ok_button="OK");
  140. os.remove(zipname); # removing the local zip backup as it is now stored on the distant server
  141. except : # If no local connection could be made
  142. try :
  143. # Try to connect via VPN and resending the backup
  144. VPNCONNECT();
  145. SMBSEND('PARIS2', 'mainserver.bonyridup.com', login, passwd, group, os.path.join('Backup', login), zipname);
  146. gui.msgbox("Backup successfully sent to the distant SMB sharing server via VPN!", title="Backup done !", ok_button="OK");
  147. os.remove(zipname);
  148. except :
  149. # If nothing worked, we leave the backup on the client in the same folder as the script, and we notify the user
  150. gui.msgbox("ERROR : Backup could NOT be sent, the backup is saved locally, in the same folder as this script. Please keep it in a safe place.", title="ERROR : Backup not sent !", ok_button="OK", image="error_button.gif");

Partager

 Auteur Stephen LARROQUE
 Date de publication 02/07/2010
 Langue français, anglais
 Type de licence gratuit
 Licence LGPL v3
 Bases de données Aucune
 Téléchargements total 40
 Téléchargements ce mois 0

Note des utilisateurs

-/10

Fonctionnalités
Blank
Interface
Blank
Stabilité
Blank
Installation
Blank
Rapport qualité/prix
Blank
Avis général
Blank
Nbre d'avis : 0

Blank



Blank


Il n'y a pas d'avis enregistrés pour le moment, vous pouvez enregistrer le vôtre.

Copyright © 2004-2012 Toocharger.com. Tous droits réservés.