I want to run a cron job to sync local files with a NAS on the same network. I need to write something to accomplish this. I was looking at scp, mv and then I found rsync. The command I came up with: rsync -a dir/ [email protected]:local directory Does this look right? If so, I looked at ISPConfig, and I found a cron job feature. But, the cron is not for a single website, but rather for a folder outside the /var/www section. Can I still out this in the cron job area? I also just look it over again, and when I read it again, in the command area, you need to give the location of a a scrript that I want to execute. If this is true, then I need to put my command noted above, into a file and the locations and name of the script needs to be put in the commandline. Right? Thanks for any help you can give Joseph
Indeed you can use rsync. If you refer to cluster server setup, you will find on how to use unison too, as an alternative.
Sounds like you will probably need to use a system cron job (ie. create it at the command line), not one setup through ISPConfig, as ISPConfig cron jobs run as the website user, so can't read much outside of the website root and related paths; you likely need to run as root to read/copy what you're after. That's correct. For a system cron job you can do the same thing, or for a simple one-liner command like rsync, just run the rsync command right from the cronjob, either way works.
I was looking at my server and in the /etc folder, there is a cron.daily folder. Could I just create a script: myscript.sh with the noted command: rsync -a dir/ [email protected]:local directory save it in the corn.daily folder. I think that I say an example of making my script executable: chmod +x /home/myfolder/rsync_dailybackup.sh then it should automatically run on a daily basis to perform the synchronization. I also noticed that as is, the folder will sync towards my second server, but not backwards? I want this to be a 1 way sync, but a full two way sync. Is my logic right? Will is work? Thanks Jsoeph
If the script in /etc/cron.daily is just that, it probably does not work as you intended. rsync -a dir/ copies the dir/ in current working directory, which may not be what you expect. If it is a script file, do Code: #!/bin/bash cd /the/dir/you/want rsync -a dir/ [email protected]:localdir Rsync copies only one way. If you want to sync also backwards you need another rsync command. But I am doubtful this works, at least without reading the rsync man page and choosing suitable options to make it sync both ways as intended. If you want both ways syncing (why?) look at unison, as @ahrasis suggested.
Hwello, I only want it one way. It wold not work for me if i twas 2 way. So, it is a 1 way sync. Good. Let me break down your script, please: #!/bin/bash - what is this for? Or, do all scripts start this way? # is a comment charater, so nothign here is executed. cd /the/dir/you/want - I need to move to the directory, that has the directory that I want to back up, right? rsync -a dir/ [email protected]:localdir - this command will do th eactual synchronizing, right? Thanks Joseph
Try proofreading your post so you no longer post questions like this: You should try to find answers yourself. Use Internet search engines, for example learning bash as search string. This is one example: https://ryanstutorials.net/linuxtutorial/scripting.php
The cronjob that @smokinjo tries to run cannot be run as web cron. Beside that, using a web cron service does not make much sense on ISPConfig servers as ISPConfig contains a web cron as well.