This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Backup to Dropbox in Ubuntu
#1
Backup to Dropbox in Ubuntu
To Backup files to Dropbox run:

Code:
wget -O dropbox_uploader.sh https://raw.githubusercontent.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh
chmod a+rx dropbox_uploader.sh
sudo mv dropbox_uploader.sh /usr/local/bin/dropbox_uploader
sudo chown root:root /usr/local/bin/dropbox_uploader
dropbox_uploader

Follow the on prompt commands because you will need to create a Dropbox API.

For tips on how to use the script see: https://github.com/andreafabrizi/Dropbox-Uploader

Once complete you can make a cron job to backup the whole site to Dropbox.

Example:

This is to backup the whole site to Dropbox once a Month.

Code:
nano /etc/cron.monthly/backup

Code:
#!/bin/bash
rm -rf /var/sentora/hostdata/zadmin/backup.zip
cd /var/sentora/hostdata/zadmin/
zip -r backup.zip public_html
dropbox_uploader delete /backup.zip
dropbox_uploader upload /var/sentora/hostdata/zadmin/backup.zip /backup.zip
exit 0

F3 will save the file and Ctrl+X will exit nano.

Next set permissions and make it executable.

Code:
sudo chmod +x /etc/cron.monthly/backup
sudo chmod 755 /etc/cron.monthly/backup

To backup databases to Dropbox daily run:

Code:
nano /etc/cron.daily/database

Code:
#!/bin/bash
mkdir -p /var/sentora/hostdata/zadmin/database
mysql -u root -p*PASSWORD* -e "FLUSH TABLES WITH READ LOCK;"
mysqlcheck --auto-repair -Aos -u root -p*PASSWORD*
mysqldump -u *USER* -p*PASSWORD* *DATABASE_NAME* > /var/sentora/hostdata/zadmin/database/*DATABASE_SAVE*.sql
*Repeat the above line for each database*
mysql -u root -p*PASSWORD* -e "UNLOCK TABLES;"
rm -rf /var/sentora/hostdata/zadmin/database.zip
cd /var/sentora/hostdata/zadmin/
zip -r database.zip database
rm -rf /var/sentora/hostdata/zadmin/database
dropbox_uploader delete /database.zip
dropbox_uploader upload /var/sentora/hostdata/zadmin/database.zip /database.zip
exit 0

F3 will save the file and Ctrl+X will exit nano.

Next set permissions and make it executable.

Code:
sudo chmod +x /etc/cron.daily/database
sudo chmod 755 /etc/cron.daily/database

What's great about doing this is Dropbox keeps backups of the files for up to 30 days (trust me this has saved my ass more then once). So it makes it pretty easy to roll back to an older backup of the database.

Also if you use the desktop client you will have synced local copies of the site and databases on your PC.

As my site is just under 2GB (zipped) I have no issues using the free version of Dropbox (free version offers up to 16 GB). So I do find this an elegant free solution to keep backups.
Reply
Thanks given by: liamgreen , InstaRobot , apinto , worksmarter
#2
RE: Backup to Dropbox in Ubuntu
This is brilliant, Have to have a look at this. Do you also know of a way to get the MySQL databases to back up to dropbox?
Thanks, 
Liam Green ~ Asenav.co.uk
Reply
Thanks given by:
#3
RE: Backup to Dropbox in Ubuntu
(12-20-2015, 08:34 AM)liamgreen Wrote: This is brilliant, Have to have a look at this. Do you also know of a way to get the MySQL databases to back up to dropbox?

Details are posted in the first post.
Reply
Thanks given by:
#4
RE: Backup to Dropbox in Ubuntu
After all this time, this still works great for me. I even found out that Dropbox keeps old versions of the backup. So if the backup is fubar dropbox probably has an older working version.
Reply
Thanks given by:
#5
RE: Backup to Dropbox in Ubuntu
Have you tried the Dropbox backup module? I'd have to recheck it,to see if it does the db also. And, find out where it is lol. I thought I had updated the old one and posted it to my repo but can't find it.(on my phone atm) will look into it.
-TGates - Project Council

SEARCH the Forums or read the DOCUMENTATION before posting!
Support Sentora and Donate: HERE

Find my support or modules useful? Donate to TGates HERE
Developers and code testers needed!
Contact TGates for more information
Reply
Thanks given by: worksmarter
#6
RE: Backup to Dropbox in Ubuntu
(08-24-2016, 04:40 PM)TGates Wrote: Have you tried the Dropbox backup module? I'd have to recheck it,to see if it does the db also. And, find out where it is lol. I thought I had updated the old one and posted it to my repo but can't find it.(on my phone atm) will look into it.

Nope. This method works really well for me. There is probably better options, but why try and fix something that isn't broken.

If there is away to do this that is hands down better, I will look into it. As it stands at the moment this works and I haven't seen another method that is better.
Reply
Thanks given by:
#7
RE: Backup to Dropbox in Ubuntu
Hi!

After run this command line:


Code:
mysqlcheck --auto-repair -Aos -u root -p'password'


The log to "datalog" table is:


Code:
databaseName.datalog
error    : Can't create new tempfile: './databaseName/datalog.TMD'


After this command the table "datalog" is marked as crashed and last repair failed.

Then trying to run this SQL

Code:
REPAIR TABLE  `datalog`

The error is:

Code:
error    : Can't create new tempfile: './databaseName/datalog.TMD'


This command doesn't work too the error is equal.

Code:
myisamchk -r /var/lib/mysql/databaseName/datalog.MYI

I'm using mysql 5.5.53

The engine for this table is MyISAM.

Do you have any idea how to fix this table now?

Best regards.
Reply
Thanks given by:
#8
RE: Backup to Dropbox in Ubuntu
Try using sudo or root user... sounds like a permission issue.
-TGates - Project Council

SEARCH the Forums or read the DOCUMENTATION before posting!
Support Sentora and Donate: HERE

Find my support or modules useful? Donate to TGates HERE
Developers and code testers needed!
Contact TGates for more information
Reply
Thanks given by:
#9
RE: Backup to Dropbox in Ubuntu
(02-21-2017, 12:16 AM)TGates Wrote: Try using sudo or root user... sounds like a permission issue.

I did it already, same result.
Reply
Thanks given by:
#10
RE: Backup to Dropbox in Ubuntu
How about:
Code:
myisamchk -r -f datalog.MYI

Also, another thing to try, is to move directly into that file's folder and run the above command, another suggestion would be to stop mysql, run the command, restart mysql.
-TGates - Project Council

SEARCH the Forums or read the DOCUMENTATION before posting!
Support Sentora and Donate: HERE

Find my support or modules useful? Donate to TGates HERE
Developers and code testers needed!
Contact TGates for more information
Reply
Thanks given by:


Possibly Related Threads…
Thread Author Replies Views Last Post
Upgrade to Ubuntu 16.04 from 14.04 HogensHero 8 27 ,139 07-18-2020, 03:13 AM
Last Post: dycott78
Ubuntu: How to Enable tls/ssl in proftpd Diablo925 2 11 ,712 04-21-2020, 03:35 AM
Last Post: iraqiboy90
Ubuntu 18.04 or 20.04 Kangarooo 1 6 ,100 03-20-2020, 11:39 AM
Last Post: Jettaman

Forum Jump:


Users browsing this thread: 1 Guest(s)