Skip to content

Instantly share code, notes, and snippets.

@gabrielkfr
Created September 4, 2013 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielkfr/6432876 to your computer and use it in GitHub Desktop.
Save gabrielkfr/6432876 to your computer and use it in GitHub Desktop.
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