I'm starting to get familiar with the shell and command line, I just want to know how I can get backups from some specific folders and send them to my server using just one command.

I set .netrc (with my user/password) for my ftp command and now it works. I just need to add " put my_file " in my alias so it runs after ftp connects.

alias save='tar -czvf backup-$(date +%Y-%m-%d).tar.gz /home/user/.bash*'
alias ftpme='ftp'

I need to add 'put my_file' in the code above so both commands run when I type ftpme.


Write your ftp put command(s), followed by a quit command, in a file (say /path/to/ftpcommands) and do:

ftp < /path/to/ftpcommands

In the ftpcommands file, you can also put your FTP user name and password (as user [username] [password]), if you like, bypassing the .netrc file.

You may also want to redirect the output of the ftp command to a log file, in case anything goes wrong. That would be something like

ftp < /path/to/ftpcommands > /path/to/ftp.log 2>&1

This will redirect all messages from the ftp command to the log file ftp.log.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.