banner
wling

wling

bilibili

Server migration record: A migration work from Debian to Debian

The main task of this migration is to transfer a server running MCSManager from one Debian server to another new Debian server, specifically involving the following content:

  • Minecraft Server: Including three server instances:
    • Velocity proxy server
    • Purpur login server
    • Leaves survival server
  • Bot Services:
    • A bot based on the Nonebot / Koishi framework, using the OneBot v11 protocol
    • A bot using the official QQ interface

The new server has also been optimized and configured, including the installation of the 1Panel panel, setting up the Zsh terminal, and introducing the plugin manager Zinit.

This migration is not just a replication of the basic environment but also an iteration of the technology stack~


Data Migration#

Using rsync to Improve Transfer Efficiency#

During the migration process, I initially tried using scp for data transfer but found the transfer speed to be less than ideal. Therefore, I switched to rsync, which supports incremental synchronization and displays transfer progress, while performing better in terms of efficiency and flexibility.

The complete command executed is as follows:

rsync -avz --progress --exclude="Config/" ***@192.168.*.*:/opt/mcsmanager/daemon/data/ /opt/mcsmanager/daemon/data/
  • -a: Archive mode, preserving file permissions, timestamps, and other metadata.
  • -v: Display detailed output.
  • -z: Compress data during transfer.
  • --progress: Show transfer progress.
  • --exclude="Config/": Exclude specific directories.

With this command, I achieved data synchronization from the old server to the new server, and the entire process was stable and efficient. Additionally, the incremental update feature of rsync is very suitable for scenarios that require multiple debugging migrations, significantly reducing the transfer time of duplicate data.


Installation and Use of 1Panel#

What is 1Panel#

1Panel is a modern open-source Linux operation and maintenance management panel designed to improve server management efficiency by simplifying operations. It has the following main advantages:

  • Efficient Management: Achieves host monitoring, file management, database management, and other functions through a web graphical interface.
  • Quick Site Setup: Deeply integrated with open-source site-building tools like WordPress and Halo, supporting one-click domain binding and SSL configuration.
  • App Store: Provides a rich collection of high-quality open-source tools and applications that users can quickly install and upgrade.
  • Safe and Reliable: Built-in firewall and log auditing features enhance system security while using container technology to reduce vulnerability exposure.
  • One-Click Backup: Supports backups to local or cloud, easily ensuring data security.

Installation Steps#

The process of installing 1Panel is very simple, and can be completed with the following command:

curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && bash quick_start.sh

Migration#

  • MariaDB
  • phpMyAdmin
  • Koishi
  • Qinglong
  • DDNS-Go
  • Uptime-Kuma
  • Alist
  • Redis

The migration of these is particularly simple, just transferring the contents of /opt/1panel/apps one by one using rsync.

If you're too lazy, it is recommended to directly migrate the entire directory /opt/1panel, tested to be feasible (

If you are interested in one of the migrations, please leave a message, and I might write another article.


Configuration of Zsh Terminal#

Why Zinit#

When configuring the terminal for the new server, I chose Zinit as the plugin manager for Zsh instead of the commonly used Oh My Zsh. The reason is Zinit's lightweight and high performance. Compared to Oh My Zsh, Zinit loads plugins faster and does not affect terminal startup time.

Zinit can be understood as "vim-plug" for Zsh, while Oh My Zsh is more like a complete framework (similar to SpaceVim). This lightweight feature allows me to flexibly customize the terminal environment as needed without introducing additional redundant features.

Installing Zsh#

First, I installed Zsh using the following command:

apt install zsh

Installing Zinit#

Next, I ran the following command to install Zinit:

bash -c "$(curl --fail --show-error --silent --location https://raw.githubusercontent.com/zdharma-continuum/zinit/HEAD/scripts/install.sh)"

After installation, I added the following configuration to the .zshrc file to load commonly used plugins (adding directly will automatically download them):

# The four kings of zsh packages
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-history-substring-search
zinit light zdharma-continuum/fast-syntax-highlighting
zinit light romkatv/powerlevel10k

# Oh My Zsh features
zinit snippet OMZ::lib/completion.zsh
zinit snippet OMZ::lib/history.zsh
zinit snippet OMZ::lib/key-bindings.zsh
zinit snippet OMZ::lib/theme-and-appearance.zsh

# Key binding
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey ',' autosuggest-accept

# Others
zinit load djui/alias-tips

Detailed Explanation of Plugin Functions#

  1. zsh-users/zsh-completions:
    Extends Zsh's auto-completion capabilities, supporting advanced completion for common tools (like git, docker), improving input efficiency.

  2. zsh-users/zsh-autosuggestions:
    Provides real-time command suggestions, automatically completing based on history and context, reducing repetitive input.

  3. zsh-users/zsh-history-substring-search:
    Supports quick searching of historical commands by substring, making historical queries more convenient with key binding features.

  4. zdharma-continuum/fast-syntax-highlighting:
    Implements command syntax highlighting, marking erroneous commands in red and correct commands in green, helping quickly locate input errors.

  5. romkatv/powerlevel10k:
    A high-performance terminal theme that provides rich visual effects and information display (such as Git status, network status, etc.), and loads extremely quickly.

  6. OMZ::lib/completion.zsh:
    Enhances Zsh's auto-completion capabilities, working in conjunction with zsh-completions.

  7. OMZ::lib/history.zsh:
    Optimizes the management of Zsh's history, supporting persistence and quick invocation.

  8. OMZ::lib/key-bindings.zsh:
    Provides more intuitive key binding functionality, enhancing terminal interaction.

  9. OMZ::lib/theme-and-appearance.zsh:
    Controls the theme and appearance settings of Zsh, working best with Powerlevel10k.

  10. djui/alias-tips:
    Provides alias suggestion functionality, for example, when entering git status, it will suggest defined aliases (like gst).


Installing x-cmd Tool#

Introduction to x-cmd#

After completing the migration, I also tried installing the x-cmd tool. It is a lightweight tool written in POSIX Shell with the following features:

  • No root permissions required: Comes with a package manager and can run without superuser privileges.
  • Modular design: Code is organized in a modular (mod) way, providing high flexibility.
  • Ready to use out of the box: Simple installation allows it to be used in various operation and maintenance scenarios.

Installation Steps#

The command to install x-cmd is as follows:

eval "$(curl https://get.x-cmd.com)"

The package management feature of x-cmd allows me to easily install some standalone tools without relying on system-level package managers, which is very convenient!

This article is synchronized and updated to xLog by Mix Space
The original link is https://mixspace.crashvibe.cn/posts/default/server-migration-with-rsync-and-zsh


Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.