I am going to automate backuping Entware partition on a regular basis.
To perform it I have installed cron from Entware and now I am going to create a script to put in cron folder to be started every week for instance.
The script should tar and gzip Entware folder in another place (Entware is on flash drive, backup should be on HDD). The number of backups can be set also.
The problem is I have no experience with dash, but bash (and a little). Unfortunately I didn't find any documentation about Merlin dash syntax. Can somebody help me to edit the script? As for now the problem is with for loop variable.
To perform it I have installed cron from Entware and now I am going to create a script to put in cron folder to be started every week for instance.
The script should tar and gzip Entware folder in another place (Entware is on flash drive, backup should be on HDD). The number of backups can be set also.
The problem is I have no experience with dash, but bash (and a little). Unfortunately I didn't find any documentation about Merlin dash syntax. Can somebody help me to edit the script? As for now the problem is with for loop variable.
Code:
#!/bin/sh
SOURCEDIR=/mnt/swapusb/entware
OUTPUTDIR=/mnt/VERBATIM_HD/Download2/Backup
NUMBERBCKS=1
if [ -f ${OUTPUTDIR}/entware.tar.gz.bck${NUMBERBCKS} ]
then
rm -f ${OUTPUTDIR}/entware.tar.gz.bck${NUMBERBCKS}
count=1
while [ $count<$NUMBERBCKS ]
do
mv ${OUTPUTDIR}/entware.tar.gz.bck${count} ${OUTPUTDIR}/entware.tar.gz.bck${$count+1}
{count++}
done
if [ -f ${OUTPUTDIR}/entware.tar.gz]
then
mv ${OUTPUTDIR}/entware.tar.gz ${OUTPUTDIR}/entware.tar.gz.bck1
tar -czf ${OUTPUTDIR}/entware.tar.gz ${SOURCEDIR}
Last edited: