So my intention is to backup some key directory with my documents and my MySQL data file etc. I have a cronjob set and it seems to work for all commands in there. Files are copied daily into a backup drive.
It's just that the one that is supposed to copy the MySQL folder contents, is just copying the folder but no contents.
I left the forward slash "/" off at the end of all the directories because I read this means to copy all the info in the directory.
Any ideas why the command create and copies the MYSQL directory to my backup location but no files. Is it a permissions thing that only the root user can do this? if so how do I get this done?
My crontab file contains:
44 4 * * * /usr/bin/rsync -av --delete /var/www/html /media/stan/Seagate\ Expansion\ Drive/backups/
33 3 * * * /usr/bin/rsync -av --delete /home/stan/documents /media/stan/Seagate\ Expansion\ Drive/backups/
03 3 * * * /usr/bin/rsync -av /var/lib/mysql /media/stan/Seagate\ Expansion\ Drive/backups/
02 2 * * * /usr/bin/rsync -av --delete /var/backups /media/stan/Seagate\ Expansion\ Drive/backups/
UPDATE: I ran the particular command from the commandline and got the below errors:
stan@corsair:~$ /usr/bin/rsync -av /var/lib/mysql /media/stan/Seagate\ Expansion\ Drive/backups/
sending incremental file list
rsync: opendir "/var/lib/mysql" failed: Permission denied (13)
mysql/
sent 73 bytes received 20 bytes 186.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0]
EDIT. Solution I used I decided that rsync is not the best tool for this since I have to stop the MySQL server. I went with @AB's mysqldump suggestion.
The final command added much needed compression which saves like 75% space on each backup:
mysqldump -u root -pmypass --all-databases | gzip > /media/stan/Seagate\ Expansion\ Drive/backups/mysql/mysqlbak-$(date "+\%Y-\%m-\%d_\%H:\%M:\%S").sql.gz
rsync
. – A.B. Jun 12 '15 at 14:34