Problem with simple beckup programm

Just starting out? Need help? Post your questions and find answers here.
BOOGIEMAN
User
User
Posts: 24
Joined: Sun Aug 07, 2005 10:29 pm
Location: Earth

Problem with simple beckup programm

Post by BOOGIEMAN »

:oops: 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 :oops:

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 ..
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post 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
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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.)
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Also, (hate to get in the way of your little project :twisted: )

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
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

it does directories with security ACLs and everything
He doesn't want everything.
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

then he can leave off the /SEC option :P

you can set multiple filters and exclusions too
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
BOOGIEMAN
User
User
Posts: 24
Joined: Sun Aug 07, 2005 10:29 pm
Location: Earth

Post 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
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post 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 :oops:
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
gonpublic2k
User
User
Posts: 40
Joined: Mon Oct 14, 2019 1:38 am

Re:

Post 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 :oops:
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!!
Post Reply