ssh-keyscan -v -p 22 -t dsa 192.168.0.1 >> ~/.ssh/known_hosts
export = ssh, ftp,read, sniff
backup = ssh, test, policy
get export via sftp = ssh, ftp
get backup via sftp = ssh, ftp, sensitive
/user group add name=backup policy=ssh,ftp,read,sniff,test,policy,sensitive /user add name=backuper password="password" group=backup address=192.168.0.2 disabled=no
svn mkdir --parents https://svn.domain.com/svn/admin/trunk/usingw01 --no-auth-cache --username user --password '*****' --message "Created empty directory for usingw01 - `date +"%Y-%m-%d %H:%M:%S"`"
mkdir -p /root/backup/trunk/usingw01/
cd /root/backup/trunk/usingw01 svn checkout https://svn.domain.com/svn/admin/trunk/usingw01 . --trust-server-cert --non-interactive --no-auth-cache --username usingw01 --password 'svnpassword'
mkdir /root/backup_scripts
vi /root/backup_scripts/backup_usingw01_to_svn.sh
#!/bin/sh # routername="usingw01" sshhost="192.168.0.1" sshport="22" sshuser="backuper" sshpassword="password" svnlocalpath="/root/backup/trunk/$routername" svnusername="usingw01" svnpassword="svnpassword" current_export_name="$routername-config-export-current.rsc" precedent_export_name="$routername-config-export-precedent.rsc" current_backup_name="$routername-config-backup-current.backup" # # sshpass -p $sshpassword ssh $sshuser@$sshhost -p $sshport export >$current_export_name diff -I "by Router" $current_export_name $svnlocalpath/$precedent_export_name # if [ "$?" -ne "0" ]; then sshpass -p $sshpassword ssh $sshuser@$sshhost -p $sshport export file=$current_export_name sshpass -p $sshpassword ssh $sshuser@$sshhost -p $sshport system backup save name=$current_backup_name sshpass -p $sshpassword sftp -oPort=$sshport $sshuser@$sshhost:$current_backup_name # mv -f $current_export_name $svnlocalpath/ mv -f $current_backup_name $svnlocalpath/ rm -f $svnlocalpath/$precedent_export_name svn add --force $svnlocalpath/$current_export_name svn add --force $svnlocalpath/$current_backup_name svn commit $svnlocalpath --trust-server-cert --non-interactive --no-auth-cache --username $svnusername --password $svnpassword --message "Automated commit of $routername at `date +"%Y-%m-%d %H:%M:%S"`" # mv -f $svnlocalpath/$current_export_name $svnlocalpath/$precedent_export_name exit 1 # # fi mv -f $current_export_name $svnlocalpath/$precedent_export_name exit 0 #
crontab -e
00 04 * * * sh /root/backup_scripts/backup_usingw01_to_svn.sh
hide-sensitive
when executing export, but this imposes its own limitations on the performance of backups. Those. you will not receive a backup when adding, for example, a user to PPP.Source: https://habr.com/ru/post/143320/
All Articles