帳號停用
將帳號設定為昨天過期
1
| sudo usermod -e $(date -d "yesterday" +"%Y-%m-%d") <user>
|
確認帳號期限
封存家目錄
1
2
3
4
| cd /home
sudo tar -I pigz -p -cvf <name of archive>.tar.gz <username>
# 或以下
sudo tar czvfp <name of archive>.tar.gz <username>
|
In addition, when doing a tar backup, it’s also good to add the following flags : p & (z/j)
-p will preserve the original file permissions
-z will compress using gzip (medium cpu usage, but less space)
-j will compress using bzip2 (lots of cpu, even less space)
-v verbose output (optional)
將封存檔移往 NFS 封存區
1
2
3
| sudo rsync -avhP --remove-source-files <name of archive>.tar.gz /nfs/Backup/home_archive
# 或以下
sudo mv <name of archive>.tar.gz /nfs/Backup/home_archive
|
移除家目錄
1
| sudo rm -rd /home/<user>
|
帳號重新啟用
重建家目錄
1
2
| cd /home
sudo tar xzvf <name of archive>.tar.gz
|
重新啟用帳號
1
| sudo usermod -e "" <user>
|
確認帳號期限
參考資料