LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-06-2021, 05:18 PM   #1
linuxpc4me
LQ Newbie
 
Registered: May 2021
Posts: 2

Rep: Reputation: Disabled
Best way to backup live lampp server


Hello!
I have a apache2 / php7.4 / mysql sever on ubuntu 20.04. To prevent me from rebuilding the whole thing again, what is the best way to do a complete nightly backup that can be restored easily? Will I need to do a mysqldump and shut down mysql, then backup, or is there something I can use that will not require this? I heard of TimeShift, Bacula, Rsync, Amanda, etc. I do not want to do a file backup (like dropbox or onedrive) I need a complete backup to restore a production server as simply and quickly as possible.
I even thought of replicating the mysql databases on another machine, and doing multiple sql dumps that would be rsync'd to another machine as well in addition to creating a complete backup of the drive
Thanks for any input
 
Old 05-06-2021, 08:25 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,328
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
If you have phpmyadmin installed, it provides backup capability, both for databases and for all files on the site.

In my experience, you can can export your mysql database without shutting dowm mysql. A web search for "phpmyadmin backup" will turn up numerous articles and tutorials.

When to back up and how often are more intriguing questions. If the files other than the database change seldom, then there may not be need to back up the non-database files as frequently as the database itself.

Many years ago, when I self-hosted my site in my early Linux days (that's how I got into Linux--to self-host my website), I wrote a script to back up my databases every night and ran it as a cron job. For what it's worth, I'd do several things differently today, but here's my old script, in case it gives you a starting point:

Code:
#!/bin/bash

#Set the variable NOW

NOW=1

#Define now as today's day-month-year-hour-minute.

NOW=$(date +%m-%d-%Y-%H-%M)

#Make the directory to hold the backup file.

mkdir /root/backups/sql/$NOW

echo "Making the directory for the backup."

cd /opt/lampp/bin

echo "Entering the Lampp directory."

mysqldump -S /opt/lampp/var/mysql/mysql.sock -u [username] -p[password] [databasename] > /root/backups/sql/$NOW/[filename].sql

echo "Backing up database."

cd

echo "Returning to root directory and exiting."

Last edited by frankbell; 05-06-2021 at 08:34 PM.
 
Old 05-06-2021, 10:38 PM   #3
linuxpc4me
LQ Newbie
 
Registered: May 2021
Posts: 2

Original Poster
Rep: Reputation: Disabled
Frank,

Thank you for the response. I have used several sql queries to backup my DB's. Yours is very nice. The greater part of hte question is: What is the most simplistic but solid way to backup the whole server (hard drive) to ensure the site ( /var/www/html) as well as the complete OS can be restored (like clonezilla)?
This full 'bare-metal-backup' (excluding /home dir) would allow me to recover to a replacement HD / server/ etc in the event of catastrophic loss.

Again, thanks for the wonderful information!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What's Best Way to Backup a web server with one hard drive Running live kitek Linux - Server 12 03-13-2011 07:28 PM
[SOLVED] How to install LAMPP so it shows up in /opt/lampp anon091 Linux - Newbie 3 09-24-2009 05:13 PM
Needing root privs to start LAMPP server paul2463 Fedora 1 08-13-2006 07:00 AM
Lampp for a production server? xpucto Linux - Newbie 9 06-10-2006 02:42 AM
seting up mail server on lampp (linux) ziggis-soft Linux - Software 5 05-24-2005 04:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration