Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
I have a dedicated server with 2 SSD (256 and 512 GB) and 6 cores.
I would like to have an automatic backup from Ubuntu drive (256GB) to back up drive (512GB).
A must-have in my opinion is a compression and save of partition table/ MBR (grub).
I believe the must-have options is the best way to recover an Ubuntu OS server.
Also some installing training within 7 weeks (1 backup every week on Monday at 10:00 UTC) rhythm would be great.
A build in recovery script is a good to have.
I believe it is useful for everyone, so a donation is possible.
I didn't quite understand the topic. Are you looking for someone to "donate" a backup script to you - or do you want to donate it to others?
What do you want to backup? I have noticed that many people tend to backup redundant data over and over. I think the easiest is to just use 7-zip with AES-256 encryption and zip whatever files/folders you need to backup. Run it in a cronjob and use SCP to move it to another server. If you just want to move it to another external drive, then using Samba is great for that. Samba is a file-share software (like Dropbox or Google Drive) but can be used on your local network.
To backup a directory (folder) using 7-zip with AES-256 encryption and password protection, run:
Bash:
sudo 7z a -tzip -mem=AES256 -p"Password123" "/path/to/folder"
I typically do this for my daily database backups (MariaDB).
My script first extracts the database tables I want to backup.
Then I get the .sql files. I create a folder for them named by the date (2024-12-16-backup) and then use 7-zip to back it up.
And I then use Samba to make a local backup and also AWS S3 to back it up on the cloud.
It all depends on what it is you want to backup. Making a full system backup every day is a bad idea as you will end up with so many GB of redudant data that never changes. I only backup new data, or data that has changed. In my case: in my database.
What you could do is just make a new directory, then copy the files you want to back up into that folder.
Zip the folder. Then upload the zip archive somewhere (SCP, FTP, email, Samba, etc..).
It does however require more work to restore it. I would have to unzip it day by day and then recover. But in my opinion I rather do that than a full db backup every day and having to avoid rewriting the data.
This encrypts a folder called "test" into a file called "test.7z" file which is password protected with "password123".
Post automatically merged:
Here is an example script you can use to backup two MariaDB database tables every day.
Make it an executable script and add it to a cronjob.
Then it's your choice to choose what to do with the file after it made the backup.
If you have Amazon S3 you can upload it there.
If you use Amazon SES you can e-mail it to yourself, for example.
If you maybe have a VPS at Hetzner you can upload it there via SCP.
I will leave that for you to do.
Bash:
#!/bin/bash
# Simple backup script by 222222 @ OtLand
#****************************************
#
# If you have any environment variables,
# place them inside /etc/environment
#
# It's optional to load them in this file.
# For example if you need to use them in your commands.
#
#****************************************
source /etc/environment
#****************************************
#
# Make a backup of a MariaDB table.
# Here we are extracting new data from the db
# into a SQL file.
#
# I choose to only select rows that were
# created yesterday.
# In my case the column I compare the date
# with is called `created` (DATETIME)
# which exists in all my tables I extract.
#
# My database user is called "Bubble" with
# the password "Tibia123".
#
# In the example, my database is called
# `otland` and the tables I backup are called
# `Players` and `Houses`.
#
# I save the file into "/opt/" and name it
# after yesterday's date.
# The path to mariadb-dump will depend where
# you installed it. If you followed my MariaDB
# guide on Otland, you will have the same path:
# See: https://otland.net/threads/how-to-build-and-install-mariadb-from-source-and-how-to-secure-your-database.288895/
#
#****************************************
sudo -E /usr/local/mysql/bin/mariadb-dump --user="Bubble" --password="Tibia123" --single-transaction --quick --no-create-db --compact --where="created >= '$(date -d "yesterday" '+%Y-%m-%d 00:00:00')' and created <= '$(date -d "yesterday" '+%Y-%m-%d 23:59:59')'" otland Players Houses > "/opt/$(date -d 'yesterday' '+%Y-%m-%d')-backup.sql"
#****************************************
#
# Here I encrypt and compress the SQL file using 7-Zip.
# You will need to install 7z (sudo apt install 7z)
# The file password will be "password123".
#
# Optional: You can make it remove the SQL
# file from the system after it made the 7z file.
# This means you dont need to clean up the system after backing up.
# To do that, add the parameter "-sdel".
# See: https://7zip.bugaco.com/7zip/MANUAL/cmdline/switches/sdel.htm
#
#****************************************
sudo 7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -mhe=on -p"password123" "/opt/$(date -d 'yesterday' '+%Y-%m-%d')-backup.7z" "/opt/$(date -d 'yesterday' '+%Y-%m-%d')-backup.sql" >/dev/null 2>&1
#****************************************
#
# Log message
# After this, it's your choice what to do
# with the .7z file. You can for example
# email it to yourself, upload to S3,
# upload via SCP (SSH) or FTP, etc...
#
#****************************************
echo "$(date +'[%Y-%m-%d %H:%M:%S]'): Generated daily database backup."
exit 1
Of course encrypting and compressing the file is not necessary. But I always recommend doing it.
Run this script with a cronjob during the night for a few weeks, and you will end up with many .7z files.
The files are always named after the day, e.g. "2025-02-05-backup.7z".
If your database ever needs to be restored, you must extract them using 7z, so you get the SQL files.
And then you must import the SQL files into your database.
You can of course edit the "where" clause in the SQL query.
The point is that you must choose what you want to backup and find a way to automate it. Since I don't know what you want to backup, you must edit the script according to your needs. The point is; automate it so it generates some file with your data. Then encrypt and compress it (it's easy with 7z). And then upload/email that file somewhere else. If your backups are really large, I recommend cleaning up the folder (in this case inside "/opt/") after you have sent the backup file somewhere else.
This encrypts a folder called "test" into a file called "test.7z" file which is password protected with "password123".
Post automatically merged:
Here is an example script you can use to backup two MariaDB database tables every day.
Make it an executable script and add it to a cronjob.
Then it's your choice to choose what to do with the file after it made the backup.
If you have Amazon S3 you can upload it there.
If you use Amazon SES you can e-mail it to yourself, for example.
If you maybe have a VPS at Hetzner you can upload it there via SCP.
I will leave that for you to do.
Bash:
#!/bin/bash
# Simple backup script by 222222 @ OtLand
#****************************************
#
# If you have any environment variables,
# place them inside /etc/environment
#
# It's optional to load them in this file.
# For example if you need to use them in your commands.
#
#****************************************
source /etc/environment
#****************************************
#
# Make a backup of a MariaDB table.
# Here we are extracting new data from the db
# into a SQL file.
#
# I choose to only select rows that were
# created yesterday.
# In my case the column I compare the date
# with is called `created` (DATETIME)
# which exists in all my tables I extract.
#
# My database user is called "Bubble" with
# the password "Tibia123".
#
# In the example, my database is called
# `otland` and the tables I backup are called
# `Players` and `Houses`.
#
# I save the file into "/opt/" and name it
# after yesterday's date.
# The path to mariadb-dump will depend where
# you installed it. If you followed my MariaDB
# guide on Otland, you will have the same path:
# See: https://otland.net/threads/how-to-build-and-install-mariadb-from-source-and-how-to-secure-your-database.288895/
#
#****************************************
sudo -E /usr/local/mysql/bin/mariadb-dump --user="Bubble" --password="Tibia123" --single-transaction --quick --no-create-db --compact --where="created >= '$(date -d "yesterday" '+%Y-%m-%d 00:00:00')' and created <= '$(date -d "yesterday" '+%Y-%m-%d 23:59:59')'" otland Players Houses > "/opt/$(date -d 'yesterday' '+%Y-%m-%d')-backup.sql"
#****************************************
#
# Here I encrypt and compress the SQL file using 7-Zip.
# You will need to install 7z (sudo apt install 7z)
# The file password will be "password123".
#
# Optional: You can make it remove the SQL
# file from the system after it made the 7z file.
# This means you dont need to clean up the system after backing up.
# To do that, add the parameter "-sdel".
# See: https://7zip.bugaco.com/7zip/MANUAL/cmdline/switches/sdel.htm
#
#****************************************
sudo 7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -mhe=on -p"password123" "/opt/$(date -d 'yesterday' '+%Y-%m-%d')-backup.7z" "/opt/$(date -d 'yesterday' '+%Y-%m-%d')-backup.sql" >/dev/null 2>&1
#****************************************
#
# Log message
# After this, it's your choice what to do
# with the .7z file. You can for example
# email it to yourself, upload to S3,
# upload via SCP (SSH) or FTP, etc...
#
#****************************************
echo "$(date +'[%Y-%m-%d %H:%M:%S]'): Generated daily database backup."
exit 1
Of course encrypting and compressing the file is not necessary. But I always recommend doing it.
Run this script with a cronjob during the night for a few weeks, and you will end up with many .7z files.
The files are always named after the day, e.g. "2025-02-05-backup.7z".
If your database ever needs to be restored, you must extract them using 7z, so you get the SQL files.
And then you must import the SQL files into your database.
You can of course edit the "where" clause in the SQL query.
The point is that you must choose what you want to backup and find a way to automate it. Since I don't know what you want to backup, you must edit the script according to your needs. The point is; automate it so it generates some file with your data. Then encrypt and compress it (it's easy with 7z). And then upload/email that file somewhere else. If your backups are really large, I recommend cleaning up the folder (in this case inside "/opt/") after you have sent the backup file somewhere else.
Thank you for that script, i never did backups but maybe its time to do it.
If i wnt to make backups of files on my computer, i can use some tool to find files that was last modified in a time frame?
in my case i dont want to backup any db tables, just files already on my system that was changed in the last 7 days.
i can use maybe "grep" for that? like find all files in many directories that was created/modified in the last 7 days, add to 7z file and upload to cloud?
Thank you for that script, i never did backups but maybe its time to do it.
If i wnt to make backups of files on my computer, i can use some tool to find files that was last modified in a time frame?
in my case i dont want to backup any db tables, just files already on my system that was changed in the last 7 days.
i can use maybe "grep" for that? like find all files in many directories that was created/modified in the last 7 days, add to 7z file and upload to cloud?
I'm not sure which command to use for that but it seems definitely possible.
1) Figure out which files you want to monitor
2) Get the latest date they were modified and compare it (i.e. <= 7 days)
3) Copy the files to a new folder
4) Compress and encrypt the folder
5) Upload the archive somewhere else