2014-02-28 95 views

回答

0

腳本(未經測試)

#!/bin/bash 

# Set path to backup directory 
BK_PATH = /path/to/backups/ 

# If 3 is there remove it 
if [ -f "${BK_PATH}3.tgz" ] 
then 
    rm -rf ${BK_PATH}3.tgz 
fi 

# If 2 is there, it becomes 3 
if [ -f "${BK_PATH}2.tgz" ] 
then 
    mv ${BK_PATH}2.tgz ${BK_PATH}3.tgz 
fi 

# If 1 is there, it becomes 2 
if [ -f "${BK_PATH}1.tgz ] 
then 
    mv ${BK_PATH}1.tgz ${BK_PATH}2.tgz 
fi 

# Create 1. 
tar czvf ${BK_PATH}1.tgz $1 

然後,在你的crontab:

0 0 * * 6 /path/to/the/script /path/the/thing/you/want/backedup 
+0

謝謝!當我們必須在linux或AIX上執行此操作時,將保留此腳本。我實際上需要在Windows上進行批處理作業,並找到了解決方案。謝謝@ J. A. Streich – Soulbroda