I’m trying to copy data from balena docker container to an external HDD. I’m using NodeJS for copying the files. The problem I’m getting is When I copy I get the acknowledgment that the file has been copied but the bytes written are zero.
I’m using bash command in the nodeJS process but still, I’m not able to copy files reliably. It is really confusing as Files show up with data if I wait long enough but there is no feedback/ acknowledgment on file copy complete.
I think when a device is mounted we get a mount path and that is a virtual location, not the exact external HDD location. So when we copy from the container it copies the files to that virtual location and sends feedback that files are copied. But after this balena internally handles the file copy and copy the files to the actual external HDD location. So if there is a way to directly write to the actual External HDD location that would be great.
Command I’m using " require('child_process').execSync(
cp -f ${source} ${destination})
Methods I have tried so far in NodeJS.
- Copy files using fs.copyFiles
- Copy files using fs.copyFileSync
- Read and write data stream.
- Copy using Bash command i.e. cp -f
Methods to verify files have been copied.
- writeStream.on(‘finish’) to check for copy complete
- matching file sizes on source and destination and trust me they match exactly but still not to the actual External HDD location just to virtual mnt/ location inside the container.
- Matching the Hash value of the files and they match exactly but still not to the actual External HDD location just to virtual mnt/ location inside the container.