Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script bash que permite llamar y pasar comandos al cliente ftp en tiempo de ejecución.
#!/bin/bash
#
# -- Declaracion de variables.
FTP_SERVER=ip_servidor
FTP_USER=nombre_usuario
FTP_PASS=contraseña_usuario
FTP_LOCAL_CD=/tmp
BACKUP_NAME=backup_opt.tar.gz
 
# -- Realizando backup de /opt.
tar -czf $FTP_LOCAL_CD/$BACKUP_NAME /opt
 
# -- Copiando archivo backup a servidor ftp.
/usr/bin/ftp -n <<EOD
  open $FTP_SERVER
  quote USER $FTP_USER
  quote PASS $FTP_PASS
  binary
  prompt
  lcd $FTP_LOCAL_CD
  put $BACKUP_NAME
  bye
EOD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.