Page 1 of 1
Problem with simple beckup programm
Posted: Sun Jun 08, 2008 7:10 pm
by BOOGIEMAN

first of all I haven't programmed for years, but ... now I need some job to be done, so I've been reading online tutorials from few programming languages - python, liberty basic, purebasic ... and first one looks too complicated, second one doesn't even have option to do what I need, and the third one looks easy, but it doesn't work ... well it's probably because of me
The Problem: I want to copy directory with all of it's subdirectories (keep the structure same), and copy files from that directories but only with extensions .xls, .doc, .docx, .pdf ... etc
Here's what I tried
Code: Select all
CopyDirectory("E:\Testing\", "F:\BackupDir", "*.mp3, *.chm", #PB_FileSystem_Recursive)
I made directory with few subdirectories just for testing, and put some small files in random directories ... but apparently this doesn't work ..
Posted: Mon Jun 09, 2008 2:05 am
by pdwyer
Not at my PC to test but:
http://www.purebasic.com/documentation/ ... ctory.html
Seems you have too many parameters for one. Also, I don't know if it would impact the copy but one of your dir params ends in a slash "\" and the other doesn't, I would make sure that they both do, for consistancy if nothing else.
The return value should tell you if you are successful or not too
Posted: Mon Jun 09, 2008 8:49 am
by Trond
You can only use one pattern. Use CopyDirectory() multiple times with different patterns. (Can be done with a linked list of string patterns and a ForEach loop.)
Posted: Mon Jun 09, 2008 10:52 am
by pdwyer
Also, (hate to get in the way of your little project

)
Do a search on the MS website for "Robocopy" I use it for backing up my system, it does directories with security ACLs and everything and has mirroring options. I have a batch file that looks like this (but longer)
Code: Select all
robocopy "f:\photos" "i:\photos" /MIR /s /SEC /NP /log:f:\MyDocs\_Robocopy.log
robocopy f:\MyDocs\ i:\MyDocs\ /MIR /s /SEC /NP /log+:f:\MyDocs\_Robocopy.log
robocopy f:\Programming\ i:\Programming\ /MIR /NP /s /SEC /log+:f:\MyDocs\_Robocopy.log
robocopy f:\mp3\ i:\mp3\ /MIR /s /SEC /NP /log+:f:\MyDocs\_Robocopy.log
But then, robocopy isn't cross platform where is PB is (or can be)
Not sure of your needs
Posted: Mon Jun 09, 2008 11:38 am
by Trond
it does directories with security ACLs and everything
He doesn't want everything.
Posted: Mon Jun 09, 2008 12:20 pm
by pdwyer
then he can leave off the /SEC option
you can set multiple filters and exclusions too
Posted: Mon Jun 09, 2008 2:48 pm
by BOOGIEMAN
Well thanks all, I solved my problem using Total Commander ... I'll try that robocopy and fixing pb code when I get home
Posted: Mon Jun 09, 2008 3:59 pm
by pdwyer
The thing I like about robocopy is that it does incremental mirrors so if files are already there and size and date are the same it doesn't overwrite them (unless you specify to)
Very useful for file server migrations. I migrated a files server across the WAN with this, took a week to copy all the data in advance (1.7TB 6 millions files) then on cutover weekend morning, kicked off an incremental mirror to update, copy and delete differences and it completed in 2hrs!
Now I backup up my PC to external USB drive once a week or so which I leave off most of the time, an incremental update mirrors all dirs in scope (130gb, 68,000 files) in just under 2mins.
Since it's not archived or compressed it's easy to verify the data is okay by opening photos and files etc. I've also had to restore from that several times.
Be warned though, Robocopy using mirror options can delete even faster than it mirrors, I've seen system admins wipe out huge shares in seconds, done a little damage once before too with it

Re:
Posted: Mon Oct 14, 2019 2:20 am
by gonpublic2k
pdwyer wrote:The thing I like about robocopy is that it does incremental mirrors so if files are already there and size and date are the same it doesn't overwrite them (unless you specify to)
Very useful for file server migrations. I migrated a files server across the WAN with this, took a week to copy all the data in advance (1.7TB 6 millions files) then on cutover weekend morning, kicked off an incremental mirror to update, copy and delete differences and it completed in 2hrs!
Now I backup up my PC to external USB drive once a week or so which I leave off most of the time, an incremental update mirrors all dirs in scope (130gb, 68,000 files) in just under 2mins.
Since it's not archived or compressed it's easy to verify the data is okay by opening photos and files etc. I've also had to restore from that several times.
Be warned though, Robocopy using mirror options can delete even faster than it mirrors, I've seen system admins wipe out huge shares in seconds, done a little damage once before too with it

Hello,
Do you have source code in PB that uses robocopy? If you do, could you share it with us - I'm trying to create a backup tool that copies a user local proflie to a roaming profile on the server, it sounds this will do the trick. I need to have ROBOCOPY run within PB though, as in a PIN application running in a form in PB. Don't know it that's even possible.
Thanks!!