mgutt 259 Posted May 1, 2020 Share Posted May 1, 2020 Is CA User Scripts race condition safe or do I need to make my own check to be sure that my script runs atomic? Quote Link to post
Masterwishx 0 Posted May 13, 2020 Share Posted May 13, 2020 Hello to everybody im new user in unraid ... i found its very powerfull System. thanks to autor of this plugin , i found its very usefull to HDSentinel linux for reporting status of all disks. im using 2 scripts . 1 - to copy file to system on boot 2 - to report and save data file *.html on disk every 10min then you add this file in HDSentinel of your windows and enjoying status of all disks in nas Thanks Quote Link to post
guilhem31 1 Posted May 16, 2020 Share Posted May 16, 2020 Hello everybody, I'm posting in this topic because I think it is the best way to achieve what I want to do... but maybe I'm wrong so don't blame me ^^ This problem is probably allready solved but I don't really understand the 38 pages of the topic to see if the detailed scripts fit my needs. I have a share called "photos" which is basically ALL my photos (stored on google photos right now). I have a Syncthing docker which sync my camera folder on my phone with a "backup" share on my server. Is there a way I can schedule every week / day the copy of my new photos stored in "backup" into the "photos" share ? I think it is but I'm not able to write any script... Quote Link to post
mgutt 259 Posted May 16, 2020 Share Posted May 16, 2020 @guilhem31 A) You could move all files with "mv": #!/bin/bash mv /mnt/user/backup/phonecamera/*.* /mnt/user/photos/phonecamera/ By that all files will be moved to "/photos/phonecamera/", but if they already exist, the script will fail. Instead you would need to force overwriting the destination by using the "-f" flag: #!/bin/bash mv -f /mnt/user/backup/phonecamera/*.* /mnt/user/photos/phonecamera/ B) If moving triggers a full new upload through your smartphone app, you should consider "rsync" to copy the files: #!/bin/bash rsync -a /mnt/user/backup/phonecamera /mnt/user/photos/phonecamera Of course there are much more possibilities. Like copying files to a year/month base subfolder structure or copying only files with specific extensions like .jpg. I'm sure you will find other solutions through a little bit research. Hints: You find the correct paths by clicking on the view icon in Unraid next to the Share: By that it displays the complete path in the headline: If you want to know how to use CA user scripts in general, this video could be helpful: Quote Link to post
guilhem31 1 Posted May 16, 2020 Share Posted May 16, 2020 2 minutes ago, mgutt said: @guilhem31 A) You could move all files with "mv": #!/bin/bash mv /mnt/user/backup/phonecamera/*.* /mnt/user/photos/phonecamera/ By that all files will be moved to "/photos/phonecamera/", but if they already exist, the script will fail. Instead you would need to force overwriting the destination by using the "-f" flag: #!/bin/bash mv -f /mnt/user/backup/phonecamera/*.* /mnt/user/photos/phonecamera/ B) If moving triggers a full new upload through your smartphone app, you should consider "rsync" to copy the files: #!/bin/bash rsync -a /mnt/user/backup/phonecamera /mnt/user/photos/phonecamera Of course there are much more possibilities. Like copying files to a year/month base subfolder structure or copying only files with specific extensions like .jpg. I'm sure you will find other solutions through a little bit research. Thanks a lot for your answer !! I need to copy the files, not move them so I'll go for the rsync script. But is it "one way" script ? I just want to copy from one directory to another, the folders won't be the same size at the end. Sorry because my english is not good enough to tell precisely what I have in my mind...! So I'll give more informations : The "photos" folder allready contains A LOT of photos, from my Google Photos account. I want to incrementally add new pics taken with my new phone in the "backup" folder (it backups all my phone storage with syncthing app), and then, once a week for example I want the "backup" photos files to be copied in the "photos" folder. It would allow this folder to contain up-to-date all time photos I shoot. I'm not sure that more informations = more clarity Quote Link to post
mgutt 259 Posted May 16, 2020 Share Posted May 16, 2020 22 minutes ago, guilhem31 said: Thanks a lot for your answer !! I need to copy the files, not move them so I'll go for the rsync script. But is it "one way" script ? I just want to copy from one directory to another, the folders won't be the same size at the end. Sorry because my english is not good enough to tell precisely what I have in my mind...! So I'll give more informations : The "photos" folder allready contains A LOT of photos, from my Google Photos account. I want to incrementally add new pics taken with my new phone in the "backup" folder (it backups all my phone storage with syncthing app), and then, once a week for example I want the "backup" photos files to be copied in the "photos" folder. It would allow this folder to contain up-to-date all time photos I shoot. I'm not sure that more informations = more clarity Yes, rsync is one-way. It won't delete in the destination, too (as long you do not set the flag "--delete"). So it's incremental as you need it. P.S. If you do not pay for the Google cloud, it will massively reduce the quality of your photos. This is the reason why I'm using Amazon Cloud instead (with Prime membership). Quote Link to post
guilhem31 1 Posted May 16, 2020 Share Posted May 16, 2020 8 minutes ago, mgutt said: P.S. If you do not pay for the Google cloud, it will massively reduce the quality of your photos. This is the reason why I'm using Amazon Cloud instead (with Prime membership). This is exactly why I need to store all my photos in original quality somwhere (at home!) My old phone took 12mpx pics, so the quality wasn't degraded, but my new phone takes much better photos. I'll try the rsync solution, thanks a lot again ! Quote Link to post
guilhem31 1 Posted May 17, 2020 Share Posted May 17, 2020 10 hours ago, mgutt said: Yes, rsync is one-way. It won't delete in the destination, too (as long you do not set the flag "--delete"). So it's incremental as you need it. Just to let you know that I managed to do what you told me, using a command like this : rsync -a "/mnt/user/backups/myphonecamera/"* /mnt/user/photos The "" is because there are spaces in the folder name, and the * helped me to copy only the folder contents Thanks again @mgutt Quote Link to post
mgutt 259 Posted May 17, 2020 Share Posted May 17, 2020 The wildcard (or globbing) character shouldn't be needed. The "-a" flag is a shortcut for "-rlptgoD" and "-r" activates copying subdirs, too. Further explanation: https://serverfault.com/a/141778/44086 Quote Link to post
Dtrain 1 Posted May 18, 2020 Share Posted May 18, 2020 Hello there, i found a realy great script for my (ZFS) Backup purpose. Unlucky me i have no clue about scripts % Co. I am still a noob and would like to know if somebody can help me to fix the errors / mistakes the script came from here https://translate.google.com/translate?hl=de&sl=auto&tl=en&u=https%3A%2F%2Fesc-now.de%2F_%2Fzfs-offsite-backup-auf-eine-externe-festplatte%2F%3Flang%3Den after several try and error i must gave up and pray somebody can help me : line 21: dialog: command not found anyone ? Quote Link to post
mgutt 259 Posted May 18, 2020 Share Posted May 18, 2020 (edited) @Dtrain Around line 21 is the command "zpool": This command is part of the zfsutils package and not available by default on an Unraid server. Maybe this is the reason? Test it by yourself. Open the terminal and type in "zpool": If it returns "command not found" than you need to install the ZFS Utilites first. P.S. You can use rsync to create incremental backups, too: #!/bin/bash # settings user_share="Music" # create full backup if [[ ! -d /mnt/user/Backup/Shares/${user_share}_$(date +%Y) ]]; then rsync -a /mnt/user/${user_share} /mnt/user/Backup/Shares/${user_share}_$(date +%Y) # create incremental backup else rsync -a --delete --link-dest=/mnt/user/Backup/Shares/${user_share}_$(date +%Y) /mnt/user/${user_share} /mnt/user/Backup/Shares/${user_share}_$(date +%Y%m%d_%H%M%S) fi This creates backups as follows: Every folder contains the full 1:1 backup of its day, but as "--link-dest" creates only hardlinks for already existing files it physically copies only changed / new files. This means its saves as much space as a ZFS snapshot does. Edited May 18, 2020 by mgutt 2 Quote Link to post
sjoerd 8 Posted May 20, 2020 Share Posted May 20, 2020 Started to use the auto vm backup script from danijo. Added a custom cron to start the script each monday morning at 3am. Prior to that I tested a the custom cron during the day. What is miss (or at least failing to find) is a log of the script. When started on de forground the webui displays script output. Is this output stored somewhere so I can monitor the progress or when it's done just to check the log if everything went oke? Quote Link to post
alturismo 91 Posted May 20, 2020 Share Posted May 20, 2020 1 hour ago, sjoerd said: Started to use the auto vm backup script from danijo. Added a custom cron to start the script each monday morning at 3am. Prior to that I tested a the custom cron during the day. What is miss (or at least failing to find) is a log of the script. When started on de forground the webui displays script output. Is this output stored somewhere so I can monitor the progress or when it's done just to check the log if everything went oke? may take a look at the user scripts page, right hand besides your cron settings u can watch or download the log 1 Quote Link to post
sjoerd 8 Posted May 20, 2020 Share Posted May 20, 2020 (edited) 1 hour ago, alturismo said: may take a look at the user scripts page, right hand besides your cron settings u can watch or download the log I must be blind. I saw those in screenshots but they were from an older version of unRaid. I took couple of seconds after I reopened the page Additional info: So yeah when I either click show log or Download log I only get a partial logfile. Last line says "Full logs for this script are available at /tmp/user.scripts/tmpScripts/unRaid_autovmbackup-0-4/log.txt". That's kinda inconvenient since that directory is not accessibly directly. Isn't there a way to consolidate all these logfiles under tools/logfiles or something? Something like that might be already there but I just started unravelling the unraid. I merely was user using my vm's but it seems I need to be a good unRaid administrator as well 😁 Edited May 20, 2020 by sjoerd added extra info Quote Link to post
mgutt 259 Posted May 20, 2020 Share Posted May 20, 2020 (edited) Show Log is partial but Download Log should be the full file I think. Or am I wrong?! Edited May 20, 2020 by mgutt Quote Link to post
alturismo 91 Posted May 20, 2020 Share Posted May 20, 2020 as its /tmp i d say its from the last reboot up Quote Link to post
mgutt 259 Posted May 26, 2020 Share Posted May 26, 2020 It would be nice to have a user-friendly input for the custom cron schedule or even an explanation. This answer helped me to understand the syntax. EDIT: Ok, now I found the "What is Cron" at the bottom of the page. Maybe you should rename it or add this popup after the "Custom Cron Schedule" gets focus. Quote Link to post
comet424 11 Posted May 27, 2020 Share Posted May 27, 2020 hi I posted a question in general question but I guess I need to post in here for script batch file help so I don't know how to delete my message in general discussion but this is what I wrote " hi i know the avidemux isnt the forum to ask for a script and i not sure if this is the right subfolder for script but i looking for help how to read all videos it be like avi moi flv mp4 even mkv i have more then 200k of videos id like a batch program to read all of them and remux them into mkv and delete all metatags then if there is any errors the script file would log it if any videos are out of sync id also want it to recreate it in a different folder with the same subdiectories... i have tried mkvtoolnix but thats going to take me forever... but 500 at a time anyone have a script or point me to the right directions as i dont know how to write any of it" Quote Link to post
Squid 2894 Posted May 27, 2020 Author Share Posted May 27, 2020 9 hours ago, mgutt said: user-friendly input for the custom cron Unfortunately, a cron generator is way outside the scope of the plugin, and a manual entry would still be needed anyways to handle the very weird entries that are possible. But if I remember, next update I'll move the "what is cron" link to someplace more visible. Quote Link to post
Cessquill 60 Posted May 27, 2020 Share Posted May 27, 2020 1 hour ago, Squid said: But if I remember, next update I'll move the "what is cron" link to someplace more visible. I wish I'd seen that before! Could never remember which "version" of cron was supported. Have generated valid but incompatible schedules several times. Quote Link to post
mgutt 259 Posted May 27, 2020 Share Posted May 27, 2020 2 hours ago, Squid said: Unfortunately, a cron generator is way outside the scope of the plugin, and a manual entry would still be needed anyways to handle the very weird entries that are possible. But if I remember, next update I'll move the "what is cron" link to someplace more visible. If realized in JS f.e. through a Pop-up, it could only fill the field. By that it would be still possible to manually edit it. Could you send me the source code of the list page? I'll try to realize that. Quote Link to post
JB7334 0 Posted May 29, 2020 Share Posted May 29, 2020 Quick one. Noticed in 6.8.3 userscripts 2020.05.11 that if I try and edit the NAME of a userscript (by clicking on the new gear icon) the editable line appears as the class for the gear icon itself "<i class="fa fa-gear"></i>" rather than the expected title for editing. The title of a user script can no longer be edited. Adding text after the font class will appear (larger class font) but the old title remains also. Is this normal or a bug? Quote Link to post
DigitalDivide 0 Posted May 30, 2020 Share Posted May 30, 2020 Hi, I just installed this but can see I am way out of my depth. I know absolultely nothing about writing scripts. Would someone be able to help me with a very minor one? I would like to copy all files from /mnt/disks/DELUGETorrents/Seedbox_Downloads to /mnt/disks/DELUGETorrents/Sonarr_Pickup/ for now I need a copy but will eventually change to move Quote Link to post
remotevisitor 31 Posted May 30, 2020 Share Posted May 30, 2020 The command you want to add to the script is: cp -R /mnt/disks/DELUGETorrents/Seedbox_Downloads/* /mnt/disks/DELUGETorrents/Sonarr_Pickup/ When you want to move the files rather than copy them change the "cp" to "mv". Quote Link to post
1216 posts in this topic Last Reply
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.