Code Monkey home page Code Monkey logo

backuphuawei's Introduction

BACKUP HUAWEI (ROUTER / SWITCH)

Backup Routers e Switchs Huawei

Arquivo: backup-huawei-ne.py

Script em python3, metodo de uso:

# backup-huawei.py {IP} {USUARIO_SSH} {SENHA} {PORTA} {IDENTIFICACAO} {TIPO router/switch}
Os comandos executados são:

Para routers:

display current-configuration | no-more

Para Switchs:

screen-length 0 temporary
display current-configuration

Arquivo: DISPOSITIVOS

Com base nisso crie um arquivo com a lista de todos seus routes e switchs qual devem gerar backups:

IP,USUARIO,SENHA,PORTA,IDENTIFICACAO,TIPO
172.19.1.1,root,123456,22,NE_8K_VS_BORDA,router
172.19.1.2,root,123456,22,SWT_CORE_S6730,switch

Arquivo gerabackup.sh

Iremos gerar um for executando o backup-fkw.py em toda nossa lista. Ajuste o mesmo informado em DIR ex /root/scripts/BackupHuawei o local onde fica seu script. Ajuste a váriavel DIRSAVE para o caminho qual deseja salvar seus backups. Será salvo um arquivo para cada equipamento no formato aaaa-mm-dd_identificacao.txt

Possível erro

Antes de rodar o script faça um SSH do seu terminal para a equipamento, para que o mesmo crie a entrada em /root/.ssh/known_hosts exemplo:

# ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 [email protected]

CRON

# crontab -e 

Adicione:

# Backup Huawei (Todos os dias 20h)
00  20  *   *   *    /root/scripts/BackupHuawei/gerabackup.sh

Reinicie o cron:

# systemctl restart cron.service

Rotina de limpeza

Adicione ao cron ou script o comando para remover os arquivos mais antigos que 60 dias:

find /home/backups/huawei/* -mtime +60 -exec rm {} \;

backuphuawei's People

Contributors

remontti avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.