It looks like you're new here. If you want to get involved, click one of these buttons!
need a backup script for my ubuntu vps which backups all sql databases including users, directories /var/www/ /etc/apache2/ /root/
and the backup should be send as an email attachment
Does anybody know some kind of script which can do this ?
There isn't going to be a script that meets your exact needs, however Bash is quite simple and you should be able to cobble one together.
Sending a backup as an email attachment is a very poor idea, you should be uploading it offsite via SCP or rsync ideally.
I'll get you started:
cp -rf /var/www/ /home/backup/www/
cp -rf /etc/apache2 /home/backup/apache2/
cp -rf /root/ /home/backup/root/
tar -czf /home/files_backup.tar.gz /home/backup/
rm -rf /home/backup/
Now you just need to dump your databases and send the files offsite.
tar zcf /backup/backup_$(date +"%Y%m%d").tar.gz /var/www/ /etc/apache2/ /root/
mysqldump -uYOUUSER -pYOUPASSWORD YOUDATABASE | gzip -9 - > /backup/db_$(date +"%Y%m%d").sql.gz)
Dump mysql and tar evry directory you need backuped and use something line ssmtp ( http://www.lowendguide.com/3/email/low-memory-usage-smtp-send-only/) to send the file.
Make sure that the total size of the email isn't larger then what your mail provider can accept.