🗃️ バックアップ.単純なbashスクリプトでdotfiles


私たちはあなたの必要なdotfilesをバックアップするスクリプトでgitリポジトリを作成するでしょう.

1 .バックアップ用のフォルダを作成する


mkdir my-dotfiles

Gitの初期化


git init

3 .ファイルリストの作成


フォルダのルートにbackup.confというファイルを作成します.
このファイルでは、バックアップに必要なすべてのファイル&フォルダを一覧表示する必要があります.EG :
~/.gitconfig
~/.profile
~/.vimrc
~/.xinitrc
~/.zshrc
私たちのバックアップスクリプトは、アイテムをループし、それぞれのフォルダにすべてをコピーします.

スクリプトを作成する


フォルダのルートにbackup.shというファイルを作成します.
これはスクリプトファイルです.以下の内容をコピーしてファイルの中に貼り付けます.
#!/bin/sh

# This script copy files mentioned inside `backup.conf` to the root of the project.

# file to look for the paths to backup.
backupPaths="./backup.conf"
# home directory path.
homeDirectory=~
# same line identifier to echo in the same line.
sameLine="\e[1A\e[K"

echo "🛑 Clearing configurations directory..."
# removing the folder with exsiting contents. we have git version anyway!
rm -rf configurations
# creating it again for backup.
mkdir configurations
sleep 1
echo -e "$sameLine✅ Configurations directory cleared."
sleep 1

echo -e "$sameLine🏁 Starting backup..."
sleep 1

# looping through the list & avoiding the empty spaces
sed '/^[ \t]*$/d' $backupPaths | while read filePath; do
  echo -e "$sameLine⏳ Copying: $filePath"

  # find & replace for ~ with home path
  findThis="~/"
  replaceWith="$homeDirectory/"
  originalFile="${filePath//${findThis}/${replaceWith}}"

  # copying the files
  cp --parents --recursive $originalFile ./configurations
  sleep 0.05
done

git add .

echo -e "$sameLine🎉 Backup finished! You can review & commit your changes."

5 .スクリプトを実行可能にする


chmod +x ./backup.sh

6 .すべての変更をコミットする


git add .
git commit -m "initial commit"

7 .スクリプトを実行する


./backup.sh
これからは、必要に応じてスクリプトファイルを実行できます.バックアップスクリプトを実行した後、backup.confファイル内のすべてのファイル&フォルダはconfigurationsフォルダにコピーされます.変更をリモートリポジトリにコミットしてプッシュします.

🛑 Make sure you are not adding any confidential files or folders to backup.conf file. eg: .ssh or private keys.


完全なコードを見るために倉庫の下のチェックアウト.アーチLinuxシステムのために作られたルートにはinstall.shスクリプトがあります.リポジトリをフォークして、お客様のニーズに合わせて変更をお気軽に.

東北大理 / Linux設定


Linux設定


🐧 Linux設定


💾 バックアップ設定

  • backup.shファイルを実行可能にします.
  • chmod +x ./backup.shファイルを実行することによって設定をバックアップします.
  • ファイルをバックアップする必要があるファイル&フォルダをbackup.shファイル内で言及する必要があります.
  • バックアップが完了し、変更をコミットします.
  • バックアップを復元する場合は、すべてのコピーをペーストするだけではなく、バックアップスクリプトを実行します.その後、ファイルの差分を使用して変更を比較し、手動で選ぶことができます.
  • 💫 パッケージのインストール

  • backup.confファイルを実行可能にします.
  • ファイルをinstall.shファイルを実行して一括インストールします.
  • chmod +x ./install.shinstall.shファイルの中にインストールされる必要があるパッケージは、
  • です.
  • サービスを有効にする必要がinstall_third_party.confファイル内に記載する必要があります.
  • スクリプトが実行された後、PCを再起動するほうが良い.
  • 第3党パッケージは、install_trusted.conf Aurヘルパーを通してインストールされます.
  • View on GitHub