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


Messages In This Thread
Backup to Dropbox in Ubuntu - by pinguy - 12-18-2015, 07:10 AM
RE: Backup to Dropbox in Ubuntu - by liamgreen - 12-20-2015, 08:34 AM
RE: Backup to Dropbox in Ubuntu - by pinguy - 12-23-2015, 09:25 AM
RE: Backup to Dropbox in Ubuntu - by pinguy - 08-24-2016, 01:23 PM
RE: Backup to Dropbox in Ubuntu - by TGates - 08-24-2016, 04:40 PM
RE: Backup to Dropbox in Ubuntu - by pinguy - 09-28-2016, 03:10 PM
RE: Backup to Dropbox in Ubuntu - by TGates - 02-21-2017, 12:16 AM
RE: Backup to Dropbox in Ubuntu - by TGates - 02-21-2017, 02:22 AM
RE: Backup to Dropbox in Ubuntu - by TGates - 02-21-2017, 05:56 AM
RE: Backup to Dropbox in Ubuntu - by TGates - 02-22-2017, 03:13 AM
RE: Backup to Dropbox in Ubuntu - by TGates - 03-08-2017, 11:27 AM

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

Forum Jump:


Users browsing this thread: 1 Guest(s)