http://www.perlmonks.org?node_id=1018189


in reply to File::Copy - locked files

Not a good idea!

Wait for the lock to be released. Otherwise you may be putting an incomplete or outdated file into your backup collection. As with all backups, shortcomings don't usually get to be a big problem... until you actually need the backup, by which time, it's too late to fix the problem.


If you didn't program it by toggling in binary, it wasn't programming!

Replies are listed 'Best First'.
Re^2: File::Copy - locked files
by packetstormer (Monk) on Feb 11, 2013 at 18:12 UTC

    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!?

      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