How to Backup Linux to 12 Destinations Easily?
2023-03-29 | Echo
Backing up your Linux system is crucial for protecting against system failures, human errors, migration risks, and cyberattacks. It ensures disaster recovery, protects valuable data, and facilitates system upgrades. Without proper backups, data loss can be devastating.
A trustworthy backup destination certainly matters when it comes to effective Linux backup. In this blog, you will know how to backup Linux to 12 destinations like remote servers, clouds, external drives, Windows, NAS, and so on for flexibility and reliability.
D1: Backup Linux to Linux Remote Server
Rsync is a command utility that can sync your local files to a remote server automatically.
1. Check whether rsync is installed or not on your PC and web server.
rsync –version
2. Install rsync if not installed.
sudo apt-get -y install rsync
3. Generate an SSH key on the local computer to authenticate the connection between the local system and the remote server. If you are asked for a password, don't enter anything and instead press Enter twice.
ssh-keygen -t rsa -b 4096 -f ~/.ssh/rsync.key
4. Establish a new user account on the remote server specifically for rsync connections and backup file storage.
sudo useradd -m username
5. Copy the public SSH key (replace the "" content with the key) to the remote server for authentication.
sudo su rsync
mkdir -m 0700 $HOME/.ssh
echo "ssh-rsa AAAAB... user@host" > $HOME/.ssh/authorized_keys
chmod 0644 $HOME/.ssh/authorized_keys
6. Open the SSH config file.
nano $HOME/.ssh/config
7. Add an entry to the ssh config file. Press Y> Enter> Ctrl+X to save and close the file.
host backup_server
hostname remote.server.ip.xx
user username
IdentityFile ~/.ssh/rsync.key
8. Test and close the connection.
ssh backup_server
exit
9. Sync the local folder to the remote server automatically with Crontab.
(crontab -l; echo "*/backup_interval_number * * * * rsync -avz --progress ~/Directory_name/ backup_server:~/ remote-directory_name> /dev/null 2>&1";) | crontab
D2: Backup Linux to Google Drive
Déjà Dup is a GUI-based backup utility for Linux based on Duplicity.
1. Start Gnome Online Accounts> Settings> Online Accounts> Add the Google account> select the features to access.
2. See the new drive named by your email address. You can copy/delete/rename files from it.
3. Some Linux distributions come with the tool preinstalled, otherwise install Déjà Dup for different systems.
# Fedora
sudo dnf install deja-dup
# Ubuntu / Debian
sudo apt install deja-dup
# CentOS / Red Hat
sudo yum install deja-dup
4. Press the super key> input deja-dup in the search box> launch the utility> click Backups> Create My First Backup.
5. Add folders to back up or ignore and click Forward.
6. Select Google Drive as the backup location and the folder to place the backups. Click Forward.
7. Grant access to the Google account.
8. Specify the encryption password to restore the backup files optionally. Click Resume Later.
9. In the application, click the hamburger menu (three stripes) at the top> click Preferences> specify the backup retention period> under Schedule, toggle on Back Up Automatically, and configure the backup frequency.
D3: Backup Linux to OneDrive
Rclone is a command line tool that syncs a Linux directory with various cloud storage services like OneDrive, Amazon S3, Google Drive, and over 40 other cloud storage.
1. Install Rclone in Debian/Ubuntu-based and Arch-based distributions respectively.
sudo apt install rclone
sudo pacman -S rclone
2. Configure Rclone> add a new remote for the first time use by selecting n> enter the remote name> hit Enter.
rclone config
3. Enter the number of the OneDrive to choose the storage> enter N or Y for advanced configurations> press Y when asked for Use auto config.
4. Enter y and hit Enter to open your browser> log into the Microsoft account> click yes for permissions.
5. Select the account type: personal or business> choose 0 to select the drive> enter Y in the next step> press Y if the configuration is ok> enter q to exit.
6. Create a folder in the home directory with mkdir command or others.
mkdir ~/OneDrive
7. Mount OneDrive. Unmount with ctrl + c.
rclone --vfs-cache-mode writes mount "remote_name": ~/OneDrive
D4: Backup Linux to Dropbox
Dropbox Uploader is a script written in BASH that enables users to upload, download, delete, list files, and perform other functions on Dropbox.
Cron is a tool that enables users to schedule various types of commands to run automatically at specified intervals.
1. Install the git package on the system.
git clone https://github.com/andreafabrizi/Dropbox-Uploader.git
cd Dropbox-Uploader
sudo chmod +x *.sh
./dropbox_uploader.sh
2. Log into Dropbox and head over to Create a new app on the Dropbox Platform page> fill out required information> select Dropbox API when prompted> click Generate token and copy it to the clipboard> paste it into the terminal in which the script asks for an access token.
3. Create the backup directory.
./dropbox_uploader.sh mkdir Linux-Backups
4. Search for cron, cronie, or similar names in the Linux package manager and install.
nano crontab -e
5. Paste the commands into the crontab after the edition. Press Ctrl + o to save the file.
06 08 * * 5 tar -zcvf backup-$(date +%Y-%m-%d).tar.gz /home/username/files-or-folders-to-back-up/;/home/username/Dropbox-Uploader/dropbox_uploader.sh upload /home/username/files-or-folders-to-back-up/backup-$(date +%Y-%m-%d).tar.gz Linux-Backup
D5: Backup Linux to Amazon S3
1. Download the open-source s3cmd plugin.
2. Create an AWS user account.
Go to AWS Services and choose IAM> choose Users from the panel and click Add User> enter the user name as you like> select Programmatic Access and Allow Management Console Access under access type> click Next: Permissions.
Choose the group created and click Next: Review> click Create User> copy or download (Download .csv) the Access key ID and Secret access key that only display once.
3. Create an Amazon S3 bucket.
Go to Services> Storage> S3> Create bucket> enter the unique name and region for the bucket> Create.
4. Install the python-setuptools.
sudo apt install python-setuptools
5. Unzip the installation file in the directory> go inside the plugin files and install the s3cmd plugin.
sudo python setup.py install
6. Configure s3cmd to access S3 bucket. Enter the keys saved in step 2, and hit enter key to leave the settings as default except for the Encryption.
s3cmd --configure
7. Enter Y to test the connection with S3 when prompted.
8. Backup Linux to an S3 bucket.
s3cmd cp s3://BUCKET1/OBJECT1 s3://BUCKET2[/OBJECT2]]
9. Syncing local Linux directory to the S3 bucket.
s3cmd sync LOCAL_DIR s3://BUCKET[/PREFIX] or s3://BUCKET[/PREFIX] LOCAL_DIR
D6: Backup Linux to Synology NAS
1. Install the Synology Active Backup for Business and open it.
2. Choose Physical Sever> Linux> Add Device> download an agent and driver on the Linux device from the Active Backup.
3. Go to the downloaded package folder and unzip it.
unzip Synology*
4. Install the application with the install.run file.
sudo ./install.run
5. Connect to the Synology NAS.
sudo abb-cli -c
6. Input the Server Address, Username, and Password. Trust the certificate when asked.
7. Customize the backup job. You can change the name, schedules, and retention policy. Select Back up to start the job.
D7: Backup Linux to QNAP NAS
1. Log into the QTS web interface as an admin, go to Control Panel> Network & File Services> Telnet /SSH > enable Allow SSH connection.
2. Create a local mount point.
mkdir /mnt/nfsfolder
3. Mount the Linux NFS share in the NAS.
[/] # mount -t nfs -o rw -O user=admin,password=mypassword 10.64.72.102:/share/CACHEDEV1_DATA/nfsshare102 /mnt/nfsfolder
[/] # df
10.64.72.102:/share/CACHEDEV1_DATA/nfsshare102 297.8G 63.9G 234.0G 21% /mnt/nfsfolder
[/] # ls -l /mnt/nfsfolder/
4. Backup to NAS.
[/] # rsync -avz --progress /mnt/nfsfolder/* /NAS/path
D8: Backup Linux to an External Hard Drive/USB
1. Plug the empty external storage device into the Linux computer.
2. In Gnome, open the Nautilus file browser> find the drive name in the sidebar> hover the mouse over the name for its path.
3. Copy the directory contents recursively to the external drive.
rsync -r /home/dave/Documents/ /media/path/
4. Check backups on the external drive.
ls
ls backups
5. Keep file attributes.
rsync -ra /home/dave/Documents/ /media/path/
6. Generate a progress report after the copy.
rsync -raP /home/dave/Documents/ /media/path/
7. Use via SSH. Enter the password on the remote machine when asked.
rsync -ravz --partial /home/dave/Documents/ network@name.local:/home/dave/Backups/
8. Automate the backup.
crontab -e
D9: Backup Linux to DVD
Dvdbackup is a tool that enables users to extract video DVDs via the command line. Its small size, fast performance, and user-friendliness make it a popular choice among users. Use Arch Linux here as an example.
1. Download and install the latest dvdbackup and libdvdcss.
2. Retrieve DVD information to display the main feature.
$ dvdbackup -i /dev/dvd -I
3. Rip the DVD.
Specify a name with -n movie_name if the DVD name is too general to refuse running.
Set the video format by adding export VIDEO_FORMAT=NTSC to ~/.bashrc if an error shows ERR: no video format specified for VMGM.
4. Extract a specific title.
$ dvdbackup -i /dev/dvd -o ~ -t 1
Create a title set like VTS_01_0.IFO and VTS_01_0.BUP. Copy the entire movie as follows.
$ mkdir ~/dvd
$ cd ~/movie_name/VIDEO_TS
$ dvdauthor -t -o ~/dvd *.VOB
Create table of contents files like VIDEO_TS.IFO and VIDEO_TS.BUP.
$ cd ~/dvd/VIDEO_TS
$ dvdauthor -o ~/dvd -T
5. Copy the main feature.
$ dvdbackup -i /dev/dvd -o ~ -F
Create table of contents files like VIDEO_TS.IFO and VIDEO_TS.BUP.
$ cd ~/movie_name/VIDEO_TS
$ dvdauthor -o ~/movie_name -T
6. Copy the whole DVD which requires about 7 GB of disk space.
dvdbackup -i /dev/dvd -o ~ -M
7. Install mkisofs as part of cdrecord package to create an ISO 9660 image.
8. Install growisofs from dvd+rw-tools to burn DVD.
9. Create the ISO file.
$ mkisofs -dvd-video -udf -o ~/dvd.iso ~/dvd # if a single title was extracted
If the whole DVD is extracted, run the following.
$ mkisofs -dvd-video -udf -o ~/dvd.iso ~/movie_name
10. Test the ISO image.
$ mplayer dvd:// -dvd-device ~/dvd.iso
11. Burn the ISO image.
$ growisofs -Z /dev/dvd=~/dvd.iso
12. Burn to DVD. Since image creation and testing are wasting time and space, we can use mkisofs and growisofs commands for a straight burning.
$ growisofs -dvd-video -udf -Z /dev/dvd ~/dvd # if a single title was extracted
Or $ growisofs -dvd-video -udf -Z /dev/dvd ~/movie_name
D10: Backup Linux to Tape
The mt command is a Linux tool that allows for basic tape control by providing a range of subcommands to a streaming tape device.
1. Rewind the tape drive.
# mt -f /dev/st0 rewind
2. Backup directory with tar.
# tar -czf /dev/st0 /example
3. Learn what block you are.
# mt -f /dev/st0 tell
4. Display the file list on tape.
# tar -tzf /dev/st0
5. Restore /example directory.
# cd /
# mt -f /dev/st0 rewind
# tar -xzf /dev/st0 etc
6. Unload the tape drive.
# mt -f /dev/st0 offline
7. Show the tape status.
# mt -f /dev/st0 status
8. Erase the tape content.
# mt -f /dev/st0 erase
9. Go to the data end of the previous record.
# mt -f /dev/nst0 eod
# mt -f /dev/nst0 bsfm 1
10. Forward the record.
# mt -f /dev/nst0 fsf 1
11. Find out more commands.
# man mt
D11: Backup Linux to Windows
1. Create the Windows share to which the Linux backups will be dumped.
2. Create a user with user permissions for the share.
3. Choose or create a user to backup the files, log in as the user, and enter the id to get the Linux numeric user ID. Become root.
4. Install samba and its client and type y to proceed when prompted.
yum install samba
yum install samba-client
5. Open cifs to other users.
chmod 4755 /sbin/mount.cifs
chmod 4755 /sbin/umount.cifs
6. Create a mounting point.
mkdir /mnt/sharename
7. Assign ownership to the user.
chown userfrom#2 /mnt/sharename
8. Specify the file and add an entry.
//hostname_or_ip_address/sharename /mnt/Windows_share_name cifs credentials=/root/smblogin,uid=#2_id,noauto,user 0 0
9. Establish or edit a file/root/smblogin and pale the commands in it.
username=WINDOWS USERNAME
password=WINDOWS PASSWORD
10. Grant the user access to the file. Add a policy to allow OUTPUT port 445 if your IPTABLES is active on your server. Then log in as the user from #2.
chown userfrom#2 /root/smblogin
chmod 600 /root/smblogin
11. Mount the Windows share.
mount /mnt/sharename
ls -la /mnt/sharename
umount /mnt/sharename
12. Write scripts to automate the backup.
#!/bin/sh
mount /mnt/sharename
cp -r /path/to/file.tar.gz /mnt/sharename/path/to/file.tar.gz
umount /mnt/sharename
13. Add an entry to the crontab of the user from #2.
crontab -e -u userfrom#2
14. Add the following command into the crontab.
# Backup at 2:00 A.M. every day. Call 'man 5 crontab' for more information
* 1 * * * /path/to/backup.sh
D12: Backup Linux to Vinchin Backup & Recovery
Vinchin Backup & Recovery is an innovative backup solution that specializes in the backup and recovery for Linux & Windows, 6 databases, NAS, and 12 virtualizations like VMware, Hyper-V, Xen, oVirt/RHEV, and more. You can backup and restore Linux servers, files/folders effortlessly with it in 4 steps.
Its main features are listed below:
Automate Linux backup with a customized schedule and an email alert.
Perform full, differential, incremental, and forever incremental backup that vary with features.
Include or exclude Linux files to backup with a wildcard.
Compress data for more storage room.
Encrypt backup data with the AES-256 standard.
Prepare an offsite backup copy for Linux recovery.
Protect all backups from malicious actors with a real-time IO monitor.
For more surprises like agent-free V2V migration across 10 virtualizations, saving data based on GFS retention, or multi-thread transfer, download the 60-day free trial now.
Backup Linux Files/Folders
1. Navigate to Physical Backup> File Backup> Backup and choose a file backup agent and the backup source. Add a wildcard filter here optionally.
2. Choose a backup node and storage (you can select NAS if you add it to the Vinchin solution).
3. Configure your backup job like schedules, backup types, data compression, encryption, retention, etc.
4. Review and submit.
Backup Linux Servers
1. Navigate to Physical Backup> Server Backup> Backup and choose a Linux host. You can select specific partitions to backup under the selected host(s).
2. Choose a backup node and storage (you can select NAS if you add it to the Vinchin solution).
3. Set up your backup strategies.
4. Review and submit.
Final Thoughts
This article introduced 12 destinations for Linux backup, and although some of them are easily accessible, they are not convenient to use and tricky for newbies. Consider Vinchin Backup & Recovery with user-friendly operations, a central web console, smart backup strategies, and an affordable price.
Share on:
Thanks for subscribing! A confirmation mail has been sent to your mailbox, please check within 48 hours.