×ðÁú¿­Ê±¹ÙÍøµÇ¼

ÔõÑùÔÚ÷è÷ë²Ù×÷ϵͳÉϾÙÐÐÎļþÖÎÀíºÍ±¸·Ý £¿

ÔõÑùÔÚ÷è÷ë²Ù×÷ϵͳÉϾÙÐÐÎļþÖÎÀíºÍ±¸·Ý £¿

÷è÷ë²Ù×÷ϵͳÊÇÒ»¿î»ùÓÚLinuxµÄ²Ù×÷ϵͳ£¬ÆÕ±éÓ¦ÓÃÓÚÖйúÕþ¸®ºÍ½ÌÓýÁìÓò¡£ÔÚ÷è÷ë²Ù×÷ϵͳÉϾÙÐÐÎļþÖÎÀíºÍ±¸·ÝÊÇÒ»ÏîÖ÷ÒªµÄʹÃü£¬ËüÄܹ»×ÊÖúÎÒÃǸüºÃµØÖÎÀíºÍά»¤Ö÷ÒªµÄÎļþºÍÊý¾Ý¡£±¾ÎĽ«ÎªÄúÏÈÈÝÔõÑùÔÚ÷è÷ë²Ù×÷ϵͳÉϾÙÐÐÎļþÖÎÀíºÍ±¸·Ý£¬²¢¸½´ø´úÂëʾÀý¡£

Ò»¡¢ÎļþÖÎÀí

½¨ÉèÎļþ¼Ð£º

ÔÚ÷è÷ë²Ù×÷ϵͳÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃmkdirÏÂÁîÀ´½¨ÉèÎļþ¼Ð¡£ÀýÈ磬ÈôÊÇÎÒÃÇÏëÔÚÄ¿½ñĿ¼Ï½¨ÉèÒ»¸öÃûΪ”documents”µÄÎļþ¼Ð£¬ÎÒÃÇ¿ÉÒÔÔËÐÐÒÔÏÂÏÂÁ

mkdir documents

µÇ¼ºó¸´ÖÆ

Òƶ¯Îļþ¼Ð£º

ÈôÊÇÎÒÃÇÏ뽫һ¸öÎļþ¼ÐÒƶ¯µ½ÁíÒ»¸öλÖã¬ÎÒÃÇ¿ÉÒÔʹÓÃmvÏÂÁî¡£ÀýÈ磬ÈôÊÇÎÒÃÇÏ뽫”documents”Îļþ¼ÐÒƶ¯µ½ÁíÒ»¸öÎļþ¼Ð”backup”Ï£¬ÎÒÃÇ¿ÉÒÔÔËÐÐÒÔÏÂÏÂÁ

mv documents backup/

µÇ¼ºó¸´ÖÆ

¸´ÖÆÎļþ¼Ð£º

Òª¸´ÖÆÒ»¸öÎļþ¼Ð£¬ÎÒÃÇ¿ÉÒÔʹÓÃcpÏÂÁî¡£ÀýÈ磬ÈôÊÇÎÒÃÇÏ뽫”documents”Îļþ¼Ð¸´ÖƵ½”backup”Îļþ¼ÐÏ£¬ÎÒÃÇ¿ÉÒÔÔËÐÐÒÔÏÂÏÂÁ

cp -r documents backup/

µÇ¼ºó¸´ÖÆ

¶þ¡¢Îļþ±¸·Ý

ÊÖ¶¯±¸·Ý£º

ÔÚ÷è÷ë²Ù×÷ϵͳÉÏ£¬ÎÒÃÇ¿ÉÒÔʹÓÃcpÏÂÁîÀ´ÊÖ¶¯±¸·ÝÎļþ¡£ÀýÈ磬ÈôÊÇÎÒÃÇÏ뱸·ÝÒ»¸öÃûΪ”example.txt”µÄÎļþµ½”backup”Îļþ¼ÐÏ£¬ÎÒÃÇ¿ÉÒÔÔËÐÐÒÔÏÂÏÂÁ

cp example.txt backup/

µÇ¼ºó¸´ÖÆ

×Ô¶¯±¸·Ý£º

ΪÁËʵÏÖ×Ô¶¯±¸·Ý£¬ÎÒÃÇ¿ÉÒÔ±àдһ¸ö¼òÆÓµÄShell¾ç±¾¡£ÒÔÏÂÊÇÒ»¸öʾÀý¾ç±¾£¬Ëü½«ÌìÌì×Ô¶¯±¸·ÝÖ¸¶¨Îļþ¼ÐÖеÄÎļþµ½ÁíÒ»¸öÎļþ¼ÐÖУº

#!/bin/bash

# ÉèÖÃÔ´Îļþ¼ÐºÍÄ¿µÄÎļþ¼Ð
source_folder="/home/user/documents"
backup_folder="/home/user/backup"

# »ñÈ¡Ä¿½ñÈÕÆÚºÍʱ¼ä
date=$(date +%Y-%m-%d)
time=$(date +%H:%M:%S)

# ½¨×°±¸·ÝÎļþ¼Ð
backup_folder_name="$date-$time"
mkdir "$backup_folder/$backup_folder_name"

# ±¸·ÝÎļþ¼ÐÖеÄÎļþµ½Ð½¨µÄ±¸·ÝÎļþ¼ÐÖÐ
cp -r "$source_folder" "$backup_folder/$backup_folder_name"

# Êä³ö±¸·ÝÍê³ÉµÄÐÅÏ¢
echo "±¸·ÝÍê³É£¡±¸·ÝÎļþ½¨ÉèÓÚ $backup_folder_name"

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊöʾÀý´úÂëÖУ¬ÎÒÃÇÊ×ÏÈÉèÖÃÁËÔ´Îļþ¼ÐºÍÄ¿µÄÎļþ¼ÐµÄ·¾¶¡£È»ºó£¬ÎÒÃÇʹÓÃdateÏÂÁî»ñÈ¡Ä¿½ñÈÕÆÚºÍʱ¼ä£¬²¢½«Æä×÷Ϊ±¸·ÝÎļþ¼ÐµÄÃû³Æ¡£½ÓÏÂÀ´£¬ÎÒÃÇͨ¹ýmkdirÏÂÁÉèÁËÒ»¸öеı¸·ÝÎļþ¼Ð¡£×îºó£¬ÎÒÃÇʹÓÃcpÏÂÁԴÎļþ¼ÐÖеÄÎļþ¸´ÖƵ½Ðµı¸·ÝÎļþ¼ÐÖС£

ΪÁËʵÏÖ×Ô¶¯±¸·Ý£¬ÎÒÃÇ¿ÉÒÔ½«ÉÏÊö¾ç±¾ÉúÑÄΪһ¸öÃûΪ”backup.sh”µÄÎļþ£¬²¢Ê¹ÓÃÒÔÏÂÏÂÁîÔÚϵͳµÄcrontabÖÐÌí¼Ó׼ʱʹÃü£º

crontab -e

µÇ¼ºó¸´ÖÆ

È»ºó£¬ÔÚ·­¿ªµÄcrontabÎļþÖÐÌí¼ÓÒÔÏÂÒ»ÐÐÄÚÈÝ£º

0 0 * * * /bin/bash /path/to/backup.sh

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁîÌåÏÖÌìÌìµÄÎçÒ¹0µã´¥·¢±¸·Ý¾ç±¾µÄÖ´ÐС£Äú¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇóµ÷½â׼ʱʹÃüµÄ´¥·¢Ê±¼ä¡£

ÒÔÉϾÍÊÇÔÚ÷è÷ë²Ù×÷ϵͳÉϾÙÐÐÎļþÖÎÀíºÍ±¸·ÝµÄ¼òÒªÏÈÈݺÍʾÀý´úÂ롣ͨ¹ýÕâЩҪÁ죬Äú¿ÉÒÔ¸üºÃµØÖÎÀíºÍ±£»¤ÄúµÄÎļþºÍÊý¾Ý¡£×£ÄúÔÚ÷è÷ë²Ù×÷ϵͳÉÏÓä¿ìµØÊÂÇéºÍѧϰ£¡

ÒÔÉϾÍÊÇÔõÑùÔÚ÷è÷ë²Ù×÷ϵͳÉϾÙÐÐÎļþÖÎÀíºÍ±¸·Ý £¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ