Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6506

Troubleshooting • Re: Script Help - Files Not Copied

$
0
0
This might be more appropriate for rsync:

Code:

#!/bin/shPATH=/usr/bin:/bin# stop on first errorset -e# copy/overwrite files from 2nd backup folder to 3rd backup folderrsync --archive --hard-links --delete /mnt/usb64/Backup/b2/ /mnt/usb64/Backup/b3/# copy/overwrite files from 1st backup folder to 2nd backup folderrsync --archive --hard-links --delete /mnt/usb64/Backup/b1/ /mnt/usb64/Backup/b2/# copy/overwrite source files to 1st backup folderrsync --archive --hard-links --delete /home/pi/folder2save/ /mnt/usb64/Backup/b1/#completesyncexit 0
rsync is really useful when copying hierarchies of files. Also, because it copies only the changed parts of the changed files it is much faster than using cp or tar.

See "man rsync" for an explanation of --archive, --hard-links, and --delete

Bash is common for interactive sessions but slower to load. So when possible it helps to used the basic POSIX shell sh instead.

Another approach would be to delete b3, rename b2 to b3, rename b1 to b2, and then create a new b1 and fill it using either rsync or cp.

Statistics: Posted by tpyo kingg — Tue Apr 29, 2025 10:04 am



Viewing all articles
Browse latest Browse all 6506

Trending Articles