I'm trying to make a backup .sh script to zip my files and to protect the zip archive with a password.
For that, I'm using the zip package (apt-get install zip) and there's an encryption option accessible via the -e parameter. How can I specify the password directly? After typing the command, I need to enter a password, and the .sh-script will be run with cron jobs.

Here's my .sh file:

zip -r -e -q ~/var/backup/backup_`date +%Y_%m_%d-%H_%M` /var/www/

Here's the result with the -e parameter:

How can I automatically set a password and then retype it in a .sh-file (that will be ran with cronjobs)?

Having your password on your hard drive in plain text is insecure. I'm sure you know that - just thought I'd point it out.
– Faheem MithaMar 28 '16 at 21:22

While it also shares the problem of being on the same hard drive, a lot of times people will place a password into an environment variable which can then be referenced by the script. That way, although someone may be able to view the script, they cannot access your user's personal files which set the environment variable to begin with. As for integrating this idea with cron, you will have to get a little creative.
– tnilesMar 28 '16 at 21:39

Well it's a VPS and there's only one user: root, and also I've put the script in the ~/ folder (root)
– SkreyMar 28 '16 at 21:41