Hey Everyone, Shell programming is something I haven't learnt or tried before.. but I kind of need it to automate backing up my website. At the moment, I have: #/bin/bash /bin/tar czPf /home/cpanelusername/etc/files/wp-content-weekly.tar.gz /home/cpanelusername/public_html/wp-content/ Code (markup): but how do I get it to email me the file wp-content-weekly.tar.gz and then delete it? Is that possible? Thanks for ur help in advance
http://www.cyberciti.biz/tips/sending-mail-with-attachment.html http://bash.cyberciti.biz/backup/backup-files-email-to-your-account/
Hmm for backup, I use rdiff-backup. It is incremental which means only the difference is stored, saving a whole heap of space, and can be restored to any given time.
Email? Ug! What are you running on the destination computer? If you are running Linux, FreeBSD or maybe even OSX, you should be able to setup a cron job to grab it and delete it. Do you have ssh or ftp access to your account? If you are running Windows, you might still be able to do something like that, but not easily.
I have a Linux OS as my server running cpanel. A cron job that can grab the backup file, email it and then delete it? How so?
No, I mean Linux running on the receiving end--the computer you are copying the file to. That's probably your home computer. In that case, the cron job could run this command, where server.com is your server. I'm assuming /home/cpanelusername/ is your account's home directory. scp server.com:etc/files/wp-content-weekly.tar.gz backups/ But if you really want to email the backup archive from the server, you can probably do that instead, assuming you don't hit a size limit somewhere. Find out if it has mailx or similar--a command-line email tool. It's probably /usr/bin/mail or /usr/bin/mailx. If it has it, find the syntax, which varies a little from version to version. Some have an a -a switch for attachments and some don't. If you have SSH access, you can use the command man mail to see. Without using the attachment switch, this command may work: base64 etc/files/wp-content-weekly.tar.gz | mail -s "Weekly backup" you@yours.com Code (markup): The base64 command encodes it as text. You'll need to unencode it at home. If you're using Windows, you may have to find a base64 utility. (Every other OS comes with one standard.)
Even though there are various graphical interfaces available for Linux the shell still is a very neat tool. The shell is not just a collection of commands but a really good programming language.You can automate a lot of tasks with it, the shell is very good for system administration tasks, you can very quickly try out if your ideas work which makes it very useful for simple prototyping and it is very useful for small utilities that perform some relatively simple tasks where efficiency is less important than ease of configuration, maintenance and portability.