2363 views|4 replies

149

Posts

0

Resources
The OP
 

Useful Tips | Don’t throw away your old phone, here’s a step-by-step guide to DIY a server [Copy link]

This article will show you how to use UrBackup and Linux Deploy to build a backup server on an old Android phone. The pollution problem of old phones is well known. I have an old phone. Although the shell has cracks and wear, the performance is still good, so I plan to reuse it.
Your old phone is likely:
  • Not that old (do you replace your computer every one or two years like you replace your phone?)

  • There are 4-8 processors and about 4GB of memory, and a built-in UPS. Just add an external hard drive and you can back up your entire home network!

Warning: This is just a project to try out what's possible. Since we're using Android, we had to jump through some hoops and are limited in many ways. This may not be the easiest way to back up your home network, or the best use of UrBackup. But once you have it set up and the server is running, you can easily manage backups for multiple machines and add storage.
Here are some limitations:
  1. The file system can only use EXT4. This is the only file system compatible with UrBackup and Android. Therefore, there is no file system level compression and other features.

  2. It is not possible to call systemd directly from a chroot environment. We will install a simple startup script that starts the UrBackup service and stops it using pkill. In addition, we will add a cronjob to start the service at system boot.

  3. UrBackup is primarily Windows-based. Although it offers full backup capabilities for Linux, the full image for Linux is still in beta. We're installing the stable version here, so our server can't support full image backups with Linux clients. However, you can create backup images on the client and then back up the directories containing those images. Finally, the UrBackup team is also working on Mac client support, but it's also in beta. For me, I don't have a Windows server and I don't want to back up my Windows laptop, so I only use UrBackup on my Linux servers.

  4. Linux Deploy has limited support for distributions and versions. I tried Centos7, Ubuntu 18.04, and Debian 10, and only Debian 10 worked without errors. UrBackup also has the worst support for Debian (no other distributions have .deb packages for ARM64).

If you're going to try this with me, here's the action plan:
  1. Root your phone. Please refer to the relevant documents for the specific steps, which will not be described here.

  2. Install Linux Deploy and deploy Debian Buster.

  3. Install the UrBackup server.

  4. Connect the client.

Keep in mind that this tutorial uses a very specific configuration, much of it adapted to using Debian on Android in a chroot environment.

Preparation

Root Android Phone
My phone is a Pixel 4a (8-core CPU, 6GB RAM). The specific model of your phone shouldn't matter too much, but different models may experience different issues. If your phone was released within the last five years, you should be fine in terms of specs. I recommend at least a 4-core CPU and 2GB of RAM, which should be enough for most home networks, but you'll have to think about backup requirements. Also don't forget that the Android OS itself will take up some resources.
If you plan to root your phone via Magisk, please note:
  • Make sure you use the correct boot.img file for your phone's current bootloader version.

  • If you are using Android 11 and the Magisk app is not working, downgrade to Android 10 and try again. I fiddled with Android 11 on my Pixel 4a for a whole day.

  • If you don't want to use Magisk, be very cautious with other tools. There are many other apps that may contain malware. CF-Auto-Root is also a good root tool, but make sure you download it from a safe source.

Linux Deploy Application
The application can be run in a chroot environment on a Debian server.
You can download the latest version from GitHub. The version in the app store is no longer maintained.
BusyBox Application
This application provides Unix utilities for Linux Deploy. There are several "Busy Box" applications available, but only this version is compatible with Linux Deploy.
You can download the latest version from GitHub. The version in the app store is no longer maintained.
Charging cable
Charging cable for mobile phone.
Connect to the server via SSH from another machine
Although it is theoretically possible to install Termux or SSH apps on your phone to do this, it is definitely easier to do it through the keyboard.

Optional Equipment (Highly Recommended)

Although you can technically store your backups on an SD card, it is not recommended. SD cards are slower, less reliable, and cannot handle continuous writes for long periods of time. If you plan to back up to an SD card, expect it to fail within a year (or even a month if you have a lot of data).
External HDD/SSD with USB cable
Size and write speed are up to you, but I care more about reliability than storage and speed. Speed is important if you have a lot of storage (hundreds or even thousands of GB). In this case, write speed is critical so that you can complete the backup in a timely manner. For reliability, we have to consider the brand. With cheap drives, be prepared for I/O errors during the backup process.
USB docking station
Depending on your phone, it may need to support micro USB or USB-C. The dock should have at least one USB port to connect to an external drive and a port for charging, but I recommend choosing one that comes with an Ethernet adapter. You can run the server over WiFi, but Ethernet is faster and more reliable.
Ethernet cable
If you are running your server on Ethernet, you will need an Ethernet cable.

Step 1: Install Linux Deploy and deploy Debian Buster

1-1. After rooting your phone, open GitHub, download the .apk packages of Linux Deploy and BusyBox, and install these two applications.
1-2. After the installation is complete, open BusyBox. During the installation, record the installation location of BusyBox. In the figure below, BusyBox is installed to "/system/xbin". We will use this location later.
1-3. Open Linux Deploy and click the settings icon in the lower right corner.
Complete the following settings:
Architecture
All Android phones are AARCH64/ARM64. Make sure it says "arm64" (or "aarch64" for other distributions).
Installation Path
The default is "${EXTERNAL_STORAGE}/linux.img". This is your SD card, and you can leave it as is (it will work on the Raspberry Pi). However, if the SD card is not inserted or is not formatted correctly, the installation will fail. I recommend installing to your internal storage. I'm assuming you won't be using the phone for anything else, as it needs to be plugged in at all times.
Image size (MB)
I recommend keeping at least 15 GB, but make sure you leave enough storage space for Android. This space will take up internal storage, so you may not end up with as much space as 50 GB.
Initialize the system
If not set to "sysv", cronjobs will not be run at boot time.
Mount
If you are not worried about future storage expansion, you can mount external block devices by simply adding their paths directly to the mount point. If you plan to expand storage in the future, you can consider logical partitions. The devices we load here can be directly accessed at boot time, but cannot be used for partitioning and formatting. However, keep in mind that the name of the block device (/dev/block/sdX) may change when you restart the phone, so you may need to check/update this configuration on reboot. If you are mounting a logical volume, the name will not change and does not need to be checked.
How to find the path to an external block device
On Android, you can find block devices at "/dev/block/sdX" (not "/dev/sdX"). To determine which sdX device is the external block device, you need to run "lsblk" on the server where the device is plugged in. Then search for the various devices and see which one matches your device (in terms of storage capacity/existing partitions). If you plugged in the device after booting, it will probably be the last device.
Note: After mounting a block device, you must unmount it or shut down the server before you can physically disconnect the block device. If you disconnect the block device without unmounting it, you will most likely lose all your data.
1-4. Go back to the home page and open the menu in the upper left corner. Select "Settings" and scroll all the way down to "PATH variable". This is where you installed BusyBox. After setting the "PATH variable", select "Update ENV".
1-5. Return to the homepage and open the menu in the upper right corner. Click "Install". You will see a real-time log of the installation. When it is finished, the log will end with "deploy". Select "START" in the lower left corner of the screen. You will now have a Debian server running on your Android phone!

Step 2: Install UrBackup Server

2-1. SSH to the newly deployed server.
The IP address is the same as your phone, and the port is 22. You can log in using the credentials you set in steps 1-3. The rest of this tutorial assumes you are logged in as root. Open Linux Deploy and you can see your IP:
2-2. Update the system.

apt update && apt upgrade -y && apt install wget
2-3. Download the .deb package of UrBackup.

wget https://hndl.urbackup.org/Server/2.4.13/urbackup-server_2.4.13_arm64.deb
This is the latest stable version.
2-4. Create a backup directory.
In this example, I set the backup directory to "/mnt/backup". If you have mounted the storage, the directory has already been created; if not, create the directory:
mkdir -p /mnt/backup
Update permissions:

chownurbackup/mnt/backupchgrp urbackup /mnt/backup
Allow UrBackup to write to this directory.
2-5. Install the startup script.
We cannot call systemd in the chroot environment, so we need to start the service manually:

/usr/bin/urbackupsrv run --config /etc/default/urbackupsrv --no-consoletime
To avoid typing this command every time, we can create a script:

nano /usr/bin/urbackupsrv-star
Copy it into the following file:

#!/bin/sh
/usr/bin/urbackupsrv run --config /etc/default/urbackupsrv --no-consoletime
Save and exit.
Add execute permissions:

chmod 755 /usr/bin/urbackupsrv-start
2-6. Start the service.

urbackupsrv-start
This command will start logging to the server. You can stop the server by pressing CTRL-C, so you will need to open another SSH session.
If you want to stop this service, just kill it:

pkill urbackup
2-7. Add scheduled jobs.
Since we can't "enable" the UrBackup service in the traditional way, we need to set up a cron job to start the service. In addition, if you disconnect the external block storage or restart the phone, the permissions of the backup directory may be restored. To ensure that these settings are preserved on reboot, we need to add a cron job.
Open crontab:

crontab -e
Add a job:

@REBOOT chown urbackup [full/path/to/backup_directory] && chgrp urbackup [full/path/to/backup_directory] && urbackupsrv-start
Save and exit.
2-8. Open the web interface.
Navigate to port 55414 of the server via a web browser:
http://YOUR_SERVER_IP:55414

Step 3: Connect to the client

3-1. Click "Add new client" on the bottom right of the screen:
3-2. Click “Add new Internet client/client behind NAT” and enter the name of the new client:
This is the hostname of the new client.
3-3. Install the client.
For Windows clients:
Follow the instructions in Download preconfigured client installer for Windows to install the client.
For Linux clients:
Make a note of the "Default authentication key" at the top, you'll need it later.
Log in to the client and run this installation script:
(Do not run scripts provided by the server)
TF=$(mktemp) && wget "https://hndl.urbackup.org/Client/2.4.11/UrBackup%20Client%20Linux%202.4.11.sh" -O $TF && sudo sh $TF; rm -f $TF
(Check for the latest client downloads.)
During the installation, the script will ask you to select a snapshot mechanism. For "LVM - Logical Volume Manager snapshots", enter "2":
After the installation is complete, please confirm that the client is running normally:

service urbackupclientbackend status
If the client is not running, run the following command:

service urbackupclientbackend start
Finally, connect the client to the server using the following command:

urbackupclientctlset-settings\-kinternet_mode_enabled-vtrue\-kinternet_server-v"YOUR_SERVER_IP"\-kinternet_server_port-v"55415"\-kcomputername-v"YOUR_CLIENT_NAME"\-k internet_authkey -v "YOUR_DEFAULT_AUTHENTICATION_KEY"
Please make sure that "YOUR_CLIENT_NAME" is the same as the hostname set in 3-2, and "YOUR_DEFAULT_AUTHENTICATION_KEY" is the key generated by the server earlier.
3-4. Configure the server.
Return to the web interface, you will find that the client is not online, click "Settings" on the top navigation bar:
Click the Internet tab on the Settings page and check the following settings:
(If all clients are local, you can uncheck "Do image backups over the internet" and "Do full file backups over the internet.")
Scroll to the bottom and click Save.
3-5. Set the backup directory.
On the "Settings" page, click "Client settings". Select "Separate settings for this client" and set the directories you want to back up in "Default directories to backup" under "File Backups". If you want to add multiple directories, you can separate them with a semicolon ";".
You can also set the backup interval here.
At the bottom, click Save.
For Linux clients, you can also set it from the client command line:

urbackupclientctl add-backupdir -d FILE_PATH
Restart the server:

pkillurbackupurbackupsrv-start
3-6. Log back into the web interface.
At this point, the client is connected. The "File backup status" may show "No paths to backup configured", but it doesn't matter, it will show this before the first backup is completed.
Also note that if you are connecting via a Linux client, image backups are not supported. However, you can run image backups via a Linux client and set the directory to which the backup image should be located.
Next, you can try backing up!
By Hannah Lee
Compiled by: Wanyue Ouyang Shuli
Source: CSDN (ID: CSDNnews)
This post is from DIY/Open Source Hardware

Latest reply

Don't sell your old phone to buy a wash basin, learn about making your own server! https://en.eeworld.com/bbs/thread-1170616-1-1.html   Details Published on 2021-10-20 00:35

赞赏

1

查看全部赞赏

 

7422

Posts

2

Resources
2
 

Awesome, great hands-on skills.

This post is from DIY/Open Source Hardware
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

1942

Posts

2

Resources
3
 

This waste is utilized to the extreme!!!

This post is from DIY/Open Source Hardware
 
 
 

28

Posts

0

Resources
4
 

This is awesome. Those who like to tinker can try it.

This post is from DIY/Open Source Hardware
 
 
 

6040

Posts

204

Resources
5
 

Don't sell your old phone to buy a wash basin, learn about making your own server! https://en.eeworld.com/bbs/thread-1170616-1-1.html

This post is from DIY/Open Source Hardware
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
What is Linux? Why did Huawei develop Hongmeng system based on Linux?

What is Linux? Why did Huawei develop Hongmeng system based on Linux? In response to the Sino-US trade friction, after ...

BlueNRG-1/2 Flash operations require mutual exclusion with BLE events

When using the Flash of BlueNRG-1/2 to store application data, you may encounter problems such as no Bluetooth signal o ...

What are the most common wireless communication (data) transmission technologies?

1. Long-distance wireless transmission technology Long-distance wireless transmission technology: Currently, the wireles ...

Discussion on the Reasons for the Temperature Drop of MOS Tubes Connected in Parallel

A circuit was originally designed to test the size of AC current. The design value is 5A maximum, with multiple rang ...

csi_pwm_init function

593820 What do device handle and device good mean? What kind of initialization function does ret = csi_pwm_init(&r, 0) ...

37 "Ten Thousand Miles" Raspberry Pi Car——ROS Learning (VSCode Debugging ROS)

This post was last edited by lb8820265 on 2022-5-10 00:27 I have introduced VSCode debugging before , which is GDB deb ...

RTD Circuit Design

RTD Circuit Design PT100/1000 meaning Common RTDs are PT100 and PT1000. 100 and 1000 mean that when the temperature is 0 ...

Canaan wants to record a video about K510. What kind of content do you hope to see? (Attached is the official information about K510)

>>The K510 board just arrived this morning . In order to help engineers get started with development, Canaan plans t ...

What is the function of the resistor at the power input end of TP4056?

This post was last edited by sky999 on 2022-8-20 03:27 Is the function of this resistor to consume some heat? Looking a ...

Connectivity and power: New Qorvo provides more comprehensive solutions for the industry

Matter was born to dissolve the ecological barriers of the Internet of Everything The Internet of Things has made the i ...

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list