If you like DNray Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

Backup Solutions for Ubuntu Server

Started by cnacer, Oct 09, 2023, 12:08 AM

Previous topic - Next topic

cnacerTopic starter

At home, I have a small Ubuntu server that I am considering using to host backups for the sites. I am wondering if there are existing solutions available for hosting backups. It is important to have backups for both the files (obtained through FTP and sftp) and mysql databases.



Additionally, it would be beneficial if the backup process were somehow intelligent, so that only modified files are downloaded each time, rather than thousands of files taking up unnecessary time and space.

Furthermore, if it is possible to create multiple backup options (such as daily, weekly, and monthly), it would be even better.

By implementing these features, the backup system would be more efficient and provide greater flexibility in terms of when and how often backups are performed.
  •  


Gaursiz

Yes, there are multiple solutions available for backing up web servers and their databases, some of which provide the intelligent and flexible features that you mentioned.

One efficient and feature-rich solution is rsync. It's a utility that synchronizes files and folders from one location to another while minimizing data transfer as it uses delta encoding when appropriate. Meaning, if only parts of files are updated, it will only transfer those parts and not the entire file.

For database backups, mysqldump is a very common utility that can handle MySQL databases.

Here's a summary of what you'd need to do:

Step 1: Install rsync and mysqldump. They're common tools and should be available from Ubuntu's repositories.

Step 2: Add a cron job that will run your backup scripts. Cron is a time-based job scheduler in Unix-like operating systems. Using Cron, you could automate backups to run daily, weekly, or at any interval of your choice.

Here is a sample script you might use for the backups:

#!/bin/bash

# Variables
backuptarget=/path/to/backup
websitepath=/path/to/website/files
databasename=your_database
databaseuser=your_user
databasepass=your_password

# Date
day=$(date +%Y%m%d)

# MySQL Dump
mysqldump -u $databaseuser -p$databasepass $databasename > $backuptarget/sqlbackup_$day.sql

# Rsync for Files
rsync -avz --delete $websitepath/ $backuptarget/filebackup_$day

# Delete older backups, you can modify this to suit your needs
find $backuptarget/* -mtime +30 -exec rm {} \;
You'd store such a script on your local machine and set it to run at the appropriate interval using cron. Be sure to replace the variables at the top with your actual paths, database names, usernames, and passwords. This script will also delete any backups older than 30 days, but you can adjust that to suit your needs.

Additionally, you could implement version control with something like git to help manage and keep track of your files. Though it's more commonly used for code, it can also be useful in other situations.

All that said, it's very important to keep in mind that this could potentially be a dangerous script if not handled with care. Ensure that you understand what it does and ensure that it does not inadvertently delete any necessary files.

Finally, make sure you have encryption and secure means to transfer files to make everything more secure.

The above describes just one scenario. Suggestion(s) on backup strategies and technologies often depend a lot on specific needs so this might not fit your needs 100%.


here are a few more advanced strategies and tools you might find helpful for your backup needs:

1. Borg Backup:
BorgBackup (short: Borg) is a deduplicating backup program that also supports compression and encryption. It's a command-line based tool loved by many for backing up to locally mounted storage as well as to remote servers using SSH.

Borg is very space-efficient because it deduplicates the data before it's written to storage. Every backup is a standalone snapshot that can be individually encrypted and compressed.

2. Duplicity:
Duplicity is another popular backup tool for Linux that offers incremental backups by archiving file differences since the last backup, rather than saving an entire copy of the files each time. This feature makes duplicity much more efficient in space usage.

Duplicity uses librsync to create the difference files, and GnuPG to encrypt and/or sign these. To transmit the backup data to the target file system, duplicity uses FTP, SSH/SCP, rsync, or Amazon's S3.

The rudimentary usage is simple:

duplicity /source_folder ftp://username@other.host/some_folder
3. Restic:
Restic is a program that does backups in a way that's fast, efficient, and secure. Restic is a command-line program that can back up data from Linux, BSD, and Mac systems to many different storage types, including self-hosted servers and cloud services.

Restic encrypts all your data with AES-256 in counter mode and authenticates it using Poly1305-AES. It uses a deduplication system, which significantly reduces the storage space needed for large archives and allows you to restore from any particular snapshot.

Before proceeding with any tool make sure to explore their dоcumentation for optimal usage tailored to your environment.

4. Bacula:
Bacula is a set of Open Source, computer programs that permits you (or the system administrator) to manage backup, recovery, and verification of computer data across a network of computers of different kinds. Bacula supports Linux, UNIX, and Windows backup clients, and a range of professional backup devices including tape libraries.

Amanda:
Amanda or "Advanced Maryland Automatic Network Disk Archiver" is a popular open-source backup and archiving software that protects multiple machines running various versions of Linux, UNIX and Microsoft Windows operating systems. It frees the system administrator from having to set up individual backup solutions for different machines and operating systems on a network.

Amanda uses native utilities to backup and can back up a large number of servers and workstations to a single large capacity tape drive. It supports tapes, disks, optical media and changers.

2. Bareos:
Bareos or "Backup Archiving Recovery Open Sourced" is a reliable and practical cross-network open-source software for backup, archiving and recovery of data across all common computers and networks. It offers different types of backup strategies like Full, Incremental, and Differential backup in a secure way.

Bareos also supports various network protocols including, SSH, FTP, SMB, among others. Furthermore, data can be encrypted on the storage media, and transport encryption is possible with the integrated TLS encryption.

3. UrBackup:
UrBackup is an easy-to-set-up open source client/server backup system that offers both image and file-based backup. Through a web interface, you can view the status of the clients, change backup configurations, or browse and restore files and directories.

UrBackup also continuously keeps track of file changes. Because of that, incremental network traffic and storage space usage are both small.

4. BackupPC:
BackupPC is a high-performance, enterprise-grade backup system for disk-to-disk backup of Linux, Windows and MacOS machines. It's known for its minimal input-output operations and low disk usage, which it achieves by pooling identical files across the network.

BackupPC is highly configurable and easy to install and maintain. Given that it uses the SMB, rsync, ftp, tar, and SSH/SCP protocols, it can back up virtually any client to a server's disk.
  •  

a112

I want to suggest using the Selectel cloud storage for backups :-)

To make file uploading more convenient, there is a prepared supload utility. It enables you to upload only the files that have changed and ensures data integrity. Additionally, you can utilize this utility in other scripts to implement more complex logic for creating backups.

For preparing a dump of mysql databases, the automysqlbackup utility is quite handy. It offers various useful features and options.

Another utility worth mentioning for creating backups with different frequencies is rsnapshot.

By incorporating these utilities into your backup strategy, you can ensure a reliable and efficient process for protecting your valuable data.
  •  

ldhsuo

Here's an alternative way that may not be the simplest, but it is a viable option:
- Set up a version control system on your personal server, such as Subversion. However, keep in mind that you will need an external IP for this.
- Add your website to the repository and create a working copy on your hosting provider.
- Create a small script on your hosting provider's cron, which will generate a database dump and perform svn ci in the root directory of your website.

While this approach may have its challenges and may not be the most straightforward method, it does offer the advantage of versioning. It can help you keep track of changes and manage your project effectively.
  •  

StassePlaiste

I'd recommend exploring existing backup solutions that cater to your specific needs. For instance, you can leverage tools like BackupPC, which supports both FTP and SFTP for file backups, and automates the process of backing up only modified files, thereby optimizing storage space and reducing bandwidth usage.

Moreover, BackupPC allows you to configure multiple backup schedules, including daily, weekly, and monthly options, providing you with the flexibility to tailor your backup strategy to your specific requirements. This feature enables you to strike a balance between data redundancy and storage efficiency.

However, if you're looking for a more comprehensive solution, you might want to consider alternatives like Bacula or Amanda. These tools offer advanced features like deduplication, compression, and encryption, which can further enhance the efficiency and security of your backup process.

On the other hand, if you're looking for a more straightforward solution, you could opt for a simple script-based approach using tools like rsync and mysqldump. This method allows for easy customization and can be tailored to your specific needs, but may require more manual configuration and maintenance.
  •  


If you like DNray forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...