Advertisement
leozeppelin

Backup com FOR

Dec 18th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.08 KB | None | 0 0
  1. #!/bin/bash
  2. # create a backup of CAPLxxx file from many machines / cria um backup do arquivo CAPLxxx de várias máquinas
  3. # VERSAO NOVA / NEW VERSION
  4. IP_SERVER=192.168.0.112
  5. PASTA_BKP=bkppdvsloja1
  6. USUARIO=Administrador
  7. SENHA=senha
  8. DATA=`date +%d%m`
  9. # lista com os ips dos pdvs
  10. LISTA="41 42 43 44 45 46 47 48"
  11. for x in $LISTA; do
  12.        # pega o numero da ecf / take the ECf number
  13.         ssh -x 192.168.0.$x "grep NROCPU /posnet/pdv.conf | awk '{print$3}' | cut -d'\"' -f2" 1>/tmp/ecf
  14.         ecf=`cat /tmp/ecf`
  15.         # copia o CAPL passando o numero da ecf no nome do novo arquivo
  16.     #copy the CAPL file passing the ecf number to the new file
  17.         scp 192.168.0.$x:/posnet/CAPL$DATA.PDV /tmp/CAPL$DATA.$ecf;
  18. done
  19. # monta o compartilhamento, zipa os arquivos, copia para o compartilhamento, remove temporários e fecha-o
  20. # do mount the share, zip the files, copy to the share folderm, remove the temp files and close the mount
  21. mount -t cifs -o username={$USUARIO},passwd={$SENHA} //{$IP_SERVER}/{$PASTA_BKP} /mnt
  22. zip /mnt/CAPLS$DATA.zip /tmp/CAPL*
  23. rm /tmp/CAPL* -f
  24. umount /mnt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement