Conjunto de mudanças 1012 no repositório publico


Ignorar:
Timestamp:
20/10/2005 14:05:09 (14 anos atrás)
Autor:
rafahelabazzanella
Mensagem:

Script para backup de zope.conf, Products e Data.fs.old

Localização:
ILPortalCasas/trunk/Extensions
Arquivos:
2 editados

Legenda:

Não Modificado
Adicionado
Removido
  • ILPortalCasas/trunk/Extensions/AppInstall.py

    r1005 r1012  
    651651
    652652def addBackup(portal):
    653         os.system("mkdir backup")
     653    DIR = INSTANCE_HOME+'backup'
     654    if os.path.exists(DIR):
     655      print >> out, 'Ja existe um diretorio com este nome na raiz da sua instancia.'
     656    else:
     657      os.system('mkdir backup')
    654658       
    655659
  • ILPortalCasas/trunk/Extensions/BackupPortalModelo.py

    r994 r1012  
    11import sys, urllib, os, time
    22from StringIO import StringIO
    3 from os import listdir
     3from os import listdir, sys
    44
    5 def instancia(self):
    6 
    7     INSTANCE_HOME = self.Control_Panel.getINSTANCE_HOME()
    8 
    9     BACKUP = INSTANCE_HOME+'/Products/ILPortalCasas/backup'
    10 
    11     PRODUCTS = INSTANCE_HOME+'/Products'
    12 
    13     ZOPE_CONF = INSTANCE_HOME+'/etc/zope.conf'
    14 
    15     DATA_OLD = INSTANCE_HOME+'/var/Data.fs.old'
    165
    176############################################################
    18 #   Faz o backup do zope.conf e do conteudo do diretorio   #
    19 #   Products dentro do diretorio backup                    #
     7#   Faz o backup do etc/zope.conf e do conteudo do         #
     8#   diretorio Products dentro do diretorio backup          #
    209############################################################
    2110
    2211def backupFile(self):
     12    INSTANCE_HOME = self.Control_Panel.getINSTANCE_HOME()
     13    BACKUP = INSTANCE_HOME+'/backup/bkp_products.txt'
     14    x = open(BACKUP,'w')
     15   # text = x.read()
     16   # return text
     17    PRODUCTS = INSTANCE_HOME+'/Products'
     18    list_prod = listdir(PRODUCTS)
    2319
    24     BACKUP = INSTANCE_HOME+'/Products/ILPortalCasas/backup/bkp_products.txt'
    25     x = open(BACKUP)
    26     text = x.read()
    27    # return text
     20    out = StringIO()
    2821
    29     PRODUCTS = INSTANCE_HOME+'/Products'
    30     xx = listdir(PRODUCTS)
    31     return xx
     22    for linha in list_prod:
     23        print >> out, linha
     24
     25    x.write(out.getvalue())
     26    x.close()
     27
     28    # faz copia do /etc/zope.conf para o diretorio backup na raiz da instancia
     29    os.system('cp etc/zope.conf backup/bkp_zope.conf')
    3230   
    33 
    34 
     31    return 'Listado conteudo do diretorio Products no arquivo backup.txt e copiado etc/zope.conf para diretorio backup'
     32   
    3533
    3634############################################################
     
    3836############################################################
    3937
    40 #def moveBackup(self):
     38def moveBackup(self):
     39    DATA_OLD = INSTANCE_HOME+'/var/Data.fs.old'
     40    if os.path.exists(DATA_OLD):
     41        os.system('gzip var/Data.fs.old')
     42        os.system('mv var/Data.fs.old.gz backup/')
     43        os.system('mv backup/Data.fs.old.gz backup/Data' + time.strftime('%d%m%Y') + '.gz')
     44        return 'Compactado Data.fs.old, renomeado e movido para o diretorio backup'
    4145
    42 #    path = ['/var/Data.fs.old']
    43 #    print "Imprimindo o path", path
    44 #    source = INSTANCE_HOME,''.join(path)
    45 #    print "Imprimindo o source", source
     46    else:
     47        return 'Arquivo Data.fs.old nao existe. Gere o arquivo, dando pack no Data.fs e rode a rotina novamente.'
    4648
    47 #target = 'Data' + time.strftime('%d%m%Y') + '.fs.tgz'
    48 #tgz_command = "tar -zcvf %s" % (target)
    49 #if os.system(tgz_command) == 0:
    50 #    print 'Successful backup to', target
    51 #    os.system ("rm INSTANCE_HOME+'/var/Data.fs.old")
    52 #else:
    53 #       print tgz_command, 'Backup FAILED'
Note: Veja TracChangeset para ajuda no uso do visualizador de conjunto de mudanças.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.