I have a cronjob that runs a bash file called mountnas.sh (it used to mount but I made the mount permanent - now it just copies)
mountnas.sh
#!/usr/bin/sh
cp -ufr /mnt/nas/Share_MC /home/mike/backup/nas/
-ufr = copy files that are updated, recurrsive and force
cronjob:
52 12 * * * /home/mike/backup/mountnas.sh > /home/mike/backup/mountnaserrorlog.txt 2>&1
it copies all files and sub folders from a NAS drive to /home/mike/backup/nas/
when i first ran it it copied everything.
Then I added a new file to it called 0.mike test2
then i rescheduled the cronjob but 0.mike test2 doesnt copy
mountnaserrorlog.txt gets created but is blank
Any help would be appreciated
Mike
cp wont copy new files
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
-
- Level 1
- Posts: 43
- Joined: Fri Feb 17, 2023 11:07 pm
Re: cp wont copy new files
I haven't gotten any replies so I decided to play with rsync and found that to be a better solution.
MY solution:
The flags:
v = verbose (increase verbosity)
r = recursive (recurse into directories)
u = update (skip files that are newer on the receiver)
l = links (copy symlinks as symlinks)
E = executability (preserve executability)
o = owner (preserve owner (super-user only))
g = group (preserve group)
t = times (preserve modification times)
delete = delete extraneous files from dest dirs
MY solution:
Code: Select all
30 18 * * * rsync -vrulEogt --delete /mnt/nas/Share_MC /home/mike/backup/nas
v = verbose (increase verbosity)
r = recursive (recurse into directories)
u = update (skip files that are newer on the receiver)
l = links (copy symlinks as symlinks)
E = executability (preserve executability)
o = owner (preserve owner (super-user only))
g = group (preserve group)
t = times (preserve modification times)
delete = delete extraneous files from dest dirs
Re: cp wont copy new files
-a option includes
-r
-l ( lower case L )
and -o.... options
Thus you could simplify that part as
-avuE
-H preserves hard-links...( which I don't recall if you needed that too or not)
-h makes it more " human readable "
... aka ...Output numbers in a more human-readable format. This makes big numbers output using larger units, with a K, M, or G suffix. If this option was specified once, these units are K (1000), M (1000*1000), and G (1000*1000*1000); if the option is repeated, the units are powers of 1024 instead of 1000.
More here... https://www.computerhope.com/unix/rsync.htm
-r
-l ( lower case L )
and -o.... options
Thus you could simplify that part as
-avuE
-H preserves hard-links...( which I don't recall if you needed that too or not)
-h makes it more " human readable "
... aka ...Output numbers in a more human-readable format. This makes big numbers output using larger units, with a K, M, or G suffix. If this option was specified once, these units are K (1000), M (1000*1000), and G (1000*1000*1000); if the option is repeated, the units are powers of 1024 instead of 1000.
More here... https://www.computerhope.com/unix/rsync.htm
Mint 21.2 Cinnamon 5.8.4
asrock x570 taichi ...bios p5.00
ryzen 5900x
128GB Kingston Fury @ 3600mhz
Corsair mp600 pro xt NVME ssd 4TB
three 4TB ssds
dual 1TB ssds
Two 16TB Toshiba hdd's
24GB amd 7900xtx vid card
Viewsonic Elite UHD 32" 144hz monitor
asrock x570 taichi ...bios p5.00
ryzen 5900x
128GB Kingston Fury @ 3600mhz
Corsair mp600 pro xt NVME ssd 4TB
three 4TB ssds
dual 1TB ssds
Two 16TB Toshiba hdd's
24GB amd 7900xtx vid card
Viewsonic Elite UHD 32" 144hz monitor