26 lines
1.1 KiB
Bash
26 lines
1.1 KiB
Bash
#!/bin/sh
|
|
|
|
# Variables
|
|
agnroot='/media/ssd1/agmission'
|
|
bkroot='/home/agmission/backups'
|
|
fname=agmdb_$(date +\%Y\%m\%d)
|
|
logfn=$bkroot/logs/agm_$(date +\%Y\%m\%d).log
|
|
uplogfn=$bkroot/logs/agm_files_$(date +\%Y\%m\%d).log
|
|
|
|
# Dump db to file then gzip
|
|
mongodump --archive=$bkroot/$fname.gz --gzip --db agmission --username "agm" --password "Agm2017" --authenticationDatabase "agmission" --forceTableScan
|
|
|
|
find $bkroot/agmdb_*.gz -mtime +11 -exec rm {} \;
|
|
find $bkroot/logs/agm_*.log $bkroot/logs/agm_files_*.log -mtime +11 -exec rm {} \;
|
|
|
|
# Sync agm db to NAS
|
|
rsync -arzh --delete --exclude '/uploads' --exclude '/sys' --exclude '/scripts' --exclude '/logs' $bkroot/ rsync://rsync@data.agnav.com:/agm/ --password-file $bkroot/scripts/pass --log-file $logfn --stats --ignore-existing
|
|
|
|
# Sync job uploaded files to NAS
|
|
rsync -arzh --delete-delay $agnroot/job-uploads/ rsync://rsync@data.agnav.com:/agm/uploads/ --password-file $bkroot/scripts/pass --log-file $uplogfn --stats --ignore-existing
|
|
|
|
# Sync the rsync log files to the destination
|
|
rsync -arzh --delete-delay $bkroot/logs/ rsync://rsync@data.agnav.com:/agm/logs/ --password-file $bkroot/scripts/pass
|
|
|
|
|