ich starte gerade meine ersten Gehversuche mit Python. Dabei soll am Ende ein kleines Backupscript rauskommen.
Das Ganze sieht im Moment folgendermaßen aus:
Code: Alles auswählen
#!/usr/bin/python
#############
# Functions #
#############
import os
import os.path
import shutil
import time
import subprocess
def GET_TIME():
return time.strftime("%d.%m.%Y %H:%M:%S", time.localtime())
def DO_RDIFF(SOURCE, TARGET, EXCLUDE, LOGFILE):
LOG = file(LOGFILE, 'a')
LOG.write(GET_TIME() + " " + SOURCE + "\n")
if os.path.isdir(TARGET) == False:
os.system("mkdir -p " + TARGET)
LOG.write(GET_TIME() + " " + TARGET + " created \n")
CMD = "rdiff-backup --print-statistics " + EXCLUDE + " " + SOURCE + " " + TARGET
subprocess.call(CMD, stdout=LOG, stderr=LOG)
LOG.write(GET_TIME() + " done \n\n")
LOG.close()
#############
# WebFolder #
#############
SOURCE = "/var/www/"
TARGET = "/var/backups/vserver/www/"
LOGFILE = "/var/backups/vserver/backup.log"
EXCLUDE = ""
EXCLUDE = EXCLUDE + " --exclude **backups"
EXCLUDE = EXCLUDE + " --exclude ***.log"
EXCLUDE = EXCLUDE + " --exclude **phptmp"
EXCLUDE = EXCLUDE + " --exclude ***.tmp"
DO_RDIFF(SOURCE, TARGET, EXCLUDE, LOGFILE)
Code: Alles auswählen
Traceback (most recent call last):
File "./rbackup2.py", line 44, in ?
DO_RDIFF(SOURCE, TARGET, EXCLUDE, LOGFILE)
File "./rbackup2.py", line 26, in DO_RDIFF
subprocess.call(CMD, stdout=LOG, stderr=LOG)
File "/usr/lib/python2.4/subprocess.py", line 413, in call
return Popen(*args, **kwargs).wait()
File "/usr/lib/python2.4/subprocess.py", line 543, in __init__
errread, errwrite)
File "/usr/lib/python2.4/subprocess.py", line 975, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Viele Grüße
Frank