Phing: Backup folder to local area network
i am using phing to backup the database folder of an eclipse project. i want to copy the folder (C:\xampp\mysql\data[projectname]) to a local area network folder (\[ip adress of backup computer]\projekte[projectname]\db). The according script is
<target name="copy_to_lan" description="copy db files to local area network">
<echo>Remove ${lan_folder}...</echo>
<delete dir="${lan_folder}" includeemptydirs="true" failonerror="true" />
<echo>Copying files from ${local_db_folder} to ${lan_folder} ..</echo>
<copy todir="${lan_folder}" verbose="true" includeemptydirs="true">
<fileset dir="${local_db_folder}">
<include name="**" />
</fileset>
</copy>
</target>
Unfortunately, when executing the script, the eclipse tells IOException: No read access to开发者_运维问答 \[ip adress of backup computer]\projekte[projectname]\db[projectname] in C:\xampp\php\PEAR\phing\system\io\PhingFile.php on line 443.
Deleting and making a folder on the backup computer do work properly, but copying the files does not due to permission errors, as it seems to be. As an alternative i did also create the folder on the backup computer by mkdir, which works but ends with the same problem, that the files could not be transferred.
thanks for any advise
I found this slideshare which mentions on slide #29 that the phing copy tasks do not work over network. You have to use native windows commands (e.g. xcopy or robocopy since Windows Vista) instead, called in the phing exec
command.
So on windows instead of using a phing task like
<mkdir dir="${build.dir}" />
use
<exec passthru="1" command="mkdir ${build.dir}" />
or in your case for copying instead of
<copy todir="${lan_folder}" verbose="true" includeemptydirs="true">
<fileset dir="${local_db_folder}">
<include name="**" />
</fileset>
</copy>
use
<exec passthru="1" command="robocopy ${local_db_folder} ${lan_folder} /MIR" />
or
<exec passthru="1" command="xcopy ${local_db_folder}\*.* ${lan_folder} /I /Y /E" />
The flags mean:
/I: If destination does not exist and copying more than one file, assumes that destination must be a directory
/Y: Suppresses prompting to confirm you want to overwrite an existing destination file
- /E: Copies directories and subdirectories, including empty ones
The passthru
attribute is optional but it outputs windows errors on those commands, useful for debugging.
That works with network drives.
精彩评论