Backup Script:
#!/usr/bin/env bash
echo "Rstudio backup has been started on $(date)" >> /var/log/rstudiobackup.log
dir1="/media/somedirectory/backup-dir"
now=$(date +"%m_%d_%Y_%H")
if [ -d "dir1" ]; then
:
else
mkdir -p /media/somedirectory/backup-dir
fi
rsync -avhz /media/dironserver/dirtobackup/ /media/somedirectory/backup-dir
cd /media/somedirectory
tar -I pigz -cf $now.tar.gz backup-dir
gpg --recipient naveed@nasheikh.com --trust-model always --encrypt --armor $now.tar.gz
mv $now.tar.gz.asc /srv/some-remote-dir
echo "Rstudio backup has been Completed on $(date)" >> /var/log/rstudiobackup.log
echo "--" >> /var/log/rstudiobackup.log
exit 0
#!/usr/bin/env bash
echo "Rstudio backup has been started on $(date)" >> /var/log/rstudiobackup.log
dir1="/media/somedirectory/backup-dir"
now=$(date +"%m_%d_%Y_%H")
if [ -d "dir1" ]; then
:
else
mkdir -p /media/somedirectory/backup-dir
fi
rsync -avhz /media/dironserver/dirtobackup/ /media/somedirectory/backup-dir
cd /media/somedirectory
tar -I pigz -cf $now.tar.gz backup-dir
gpg --recipient naveed@nasheikh.com --trust-model always --encrypt --armor $now.tar.gz
mv $now.tar.gz.asc /srv/some-remote-dir
echo "Rstudio backup has been Completed on $(date)" >> /var/log/rstudiobackup.log
echo "--" >> /var/log/rstudiobackup.log
exit 0
Place this in /usr/local/bin ( hence no PATH problems )
Packages to install :
apt install pigz
Install cron job
crontab -e
30 3 * * SUN /usr/local/bin/backupper.sh
30 3 * * 1-6 /usr/bin/rsync -avhz /media/dironserver/dirtobackup/ /media/somedirectory/backup-dir
Job Finish
Install cron job
crontab -e
30 3 * * SUN /usr/local/bin/backupper.sh
30 3 * * 1-6 /usr/bin/rsync -avhz /media/dironserver/dirtobackup/ /media/somedirectory/backup-dir
Job Finish
No comments:
Post a Comment