Hi:<div><br></div><div>Hoping you guys can help out a python noob here.</div><div><br></div><div>I have a list of machines that I am backing up flat files from to one central machine. I need to:</div><div>a) Map Drives and b) run robocopy</div>
<div><br></div><div>I am iterating through a text file that has the share names and the and directory that I want to be created:</div><div><br></div><div><div><br></div><div><div>count = 0</div><div>alphabet = 'klmnopqrstuv'</div>
</div><div>today = datetime.date.today()</div><div>backup_servers = {}</div><div>f = open('c:/test/backup_shares.txt')</div><div>for line in f:</div><div> backup_server = line.split(',')</div><div> backup_servers[ backup_server[0]]=backup_server[1]</div>
<div>for i, v in backup_servers.items():</div><div> backup_shares = i</div><div> archive_dir = v.strip()</div><div> archive_dir += str(today)</div><div> drive_letter = alphabet[count]</div><div> count += 1</div>
<div><br></div><div> </div><div>The above creates a dictionary and I iterate through that. </div></div><div><br></div><div>backup_shares = '\\server_name\c$' for example and archive_dir is the directory on the local machine that I will create with a timestamp to backup the files to on the local machine example "d:\backup_dir\03-03-2011\files</div>
<div><br></div><div>What I want to do is map a drive, which is why the alphabet string. I iterate through that and then get k first backup dir, etc.</div><div><br></div><div>I'm not sure what method to call to map a drive or how the best way to call robocopy is. I don't have the choice of using IronPython. I have the win32 modules. </div>
<div>And this works: win32net.NetUseAdd(None,1,{'remote':r'\\server_name\c$','local':'K:'})</div><div>However, I want to use the variable backup_server and insert the drive_letter variable in the script snippet, but I haven't been able to make that work. Any suggestions?</div>
<div><br></div><div>Also, suggestions and examples on calling robocopy?</div><div><br></div><div>Thanks so much!</div><div><br></div><div>Becky </div><div><br></div>