You know the client has a command to backup the wallet, right?
How do I call the command to backup the wallet file from an active process? And isn't the backup command only for the daemon, or is it for the GUI version too?
The GUI will accept commands too if run with the "-server" option or if you specify "server=1" in bitcoin.conf. You can then use the "backupwallet" JSON-RPC command to backup the wallet. From the command-line, that would be "bitcoind backupwallet /output/file".