Re: file backup in windows



k.i.n.g. wrote:
Hi ALL,

I am a newbee programmer and started of with python recently. I am
trying write a script which backups outlook (.pst ) files everytime I
shutdown my system. I have writtern following code after some findings
on net. My .pst file path is as follows

" c:\documents and settings\060577\Local Settings\Application
Data\Microsoft\Outlook "
where 060577 represents username. I want my script to identigy the user
logged in and go to the resp outlook folder or should be able to read
outlook store directory path from registry and the copy the files to
the desired path.

---------------------------------------------------
how can i make the following code work, I have probelm with filepath
declaration.
---------------------------------------------------
import os, shutil
filepath = ' C:\\Documents and Settings\\060577\\Local
Settings\\Application Data\\Microsoft\\Outlook\\* '
backup = ' D:\\temp\\outlook '

Aside: having a space at the beginning and/or end of the filename has
no good effect and may cause problems, so don't do it.

os.system ("xcopy /s %s %s" % (filepath, backup))
-----------------------------------------

It's always a good idea *before* you write an os.system call on *any*
operating system to try a few sample commands at the command line. You
would find in this case that the problem exists there too -- it has
nothing to do with Python. The problem is that the first argument
*contains* spaces, but the Windows command processor splits the command
line on spaces, so it thinks the first argument is 'C:\\Documents'. On
both the command line and in your script, you will need to wrap quotes
around each argument that does/could contain spaces.

[untested]
os.system ('xcopy /s "%s" "%s"' % (filepath, backup))

Hint: you should find it easier using raw strings for Windows
filenames:
backup = r'D:\temp\outlook'

HTH,
John

.



Relevant Pages

  • Re: Need some small help on shell script - delete old files
    ... the grep are then sent to xargs to issue the rm command. ... gzip of $FILENAME at the end is not necessary as far as I can tell ...  Could this possibly be from this script? ... Also not sure why the qzip did not run on last night's backup. ...
    (comp.unix.shell)
  • Re: backup script directory errors fixed, now it cant find the eof
    ... I run the script and it finds a premature end of file on line 53? ... The:command not founde 21,30,31 are just blank lines. ... # full and incremental backup script ... # The rest of the time an incremental backup is made. ...
    (comp.unix.shell)
  • Re: remote server backup script
    ... > Just type away at the command line. ... Make a backup of whatever you want ... > command line, in a script. ... >>the server ssh key on the clients machine). ...
    (comp.os.linux.misc)
  • Re: Sharing Custom Task Form with Outside Vendor
    ... Now I created the form not in VBA, but in the standard forms design application using the Tools menu in Outlook. ... the only way to associate code with a button is to choose the button and click on "view code" from the form design menu bar. ... However, I believe my script is trying to run, because when I click the command button and nothing happens, I then go to close my form, and the debugger comes up. ...
    (microsoft.public.outlook.program_forms)
  • Re: Need some small help on shell script - delete old files
    ... the grep are then sent to xargs to issue the rm command. ... gzip of $FILENAME at the end is not necessary as far as I can tell ... I am running the script and have noticed that the file names have been ... here is a list of the files in the backup directory: ...
    (comp.unix.shell)