Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: File::Copy - locked files

by packetstormer (Monk)
on Feb 11, 2013 at 18:12 UTC ( #1018205=note: print w/replies, xml ) Need Help??


in reply to Re: File::Copy - locked files
in thread File::Copy - locked files

Agreed!

What about files that are in use though, continually (or close to). Is there any accepted method for dealing with this type of thing? Suppose it's a small Access database with a lock on it (in use by a Windows service that is always running!). Is there any shadowing copying libraries for Perl!?

Replies are listed 'Best First'.
Re^3: File::Copy - locked files
by afoken (Abbot) on Feb 12, 2013 at 04:46 UTC

    Recent Windows versions have a special service (Volume Shadow Service? Use Google!) for this problems, it allows you to take some kind of snapshot of the filesystem. All modifications after the snapshot do not affect your program, so you can safely copy files from a mounted filesystem. Of course, this service can't guarantee that all open files are in a consistent state.

    Regarding your locked Access database: Shut down the service, then backup or make at least a copy of the database file, then restart the service and exclude the original, locked file.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      Regarding your locked Access database: Shut down the service, then backup or make at least a copy of the database file, then restart the service and exclude the original, locked file.

      Seems crude :) i'll bet there is a way without shutting down the service

        i'll bet there is a way without shutting down the service

        Perhaps. I don't know. Read the Access documentation.

        You need to make sure that the database file is in a consistent state, and that this state does not change for the time the backup program processes the database file. If it is not consistent or changes while the backup program processes the file, the resulting file on the backup media is inconsistent in the best case, binary garbage in the worst case.

        A clean shutdown of the service makes sure that the database file is consistent and does not change while the backup program runs. The procedure shutdown - copy - restart - backup the copy reduces the downtime of the service to the time needed to create a consistent copy of the database file.

        "Real" database engines usually offer tools or hooks for backup purposes. Oracle has tools to create a file containing a consistent backup of a running database, MS SQL Server offers a plugin API for backup programs, as far as I remember.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1018205]
help
Chatterbox?
[erix]: yeah... trepidation
Corion quivers with antici...
[choroba]: if you turn off autocommit and run a prepared statement which fails, the transaction is automatically rolled back, at least in DBD::Pg
[erix]: at least, I'll know where to find the documentation :P
[choroba]: but if there's no prepared statement, there's no rollback
[choroba]: the rollback happens when deallocating the prepared statement in error state.
[choroba]: is this something that Pg enforces, or just a consequence of the Perl implementation?
[choroba]: also, does it make any sense? We run different statements generated from input structures, sometimes prepared statements are involved, sometimes not. We want the behaviour to be consistent.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2017-09-19 12:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (220 votes). Check out past polls.

    Notices?