The other day I needed to migrate a directory containing a lot of files from one location on my Linux server to another. Днями мені потрібно перейти в каталог, що містить безліч файлів з одного місця на моєму сервері Linux на іншій. There are a number of ways I could do this. Є кілька способів я міг би це зробити. Using a simple cp command could have done the trick. За допомогою простої команди CP міг зробити трюк. However, as the data I was copying was a database and I wanted to make sure that the copying was done perfectly, I looked on the Internet and found a brilliant one line bash solution for this. Однак, оскільки дані я була копіювання бази даних, і я хотів, щоб переконатися, що копіювання було зроблено чудово, я подивився в Інтернеті і знайшли блискуче одному рядку Bash рішення для цього.
I wanted to move the contents of the directory /var/lib/mysql to /opt/mysql . Я хотів, щоб перемістити вміст каталогу / VAR / LIB / MySQL в / Opt / MySQL. First I changed to the directory /var/lib/mysql : Спочатку я змінив у директорію / VAR / LIB / MySQL:
# cd /var/lib/mysql # CD / VAR / LIB / MySQL
Then I ran the following one liner to do the magic for me. Тоді я побіг наступні Один балон зробити магію для мене.
# tar cf – * | ( cd /opt/mysql; tar xfp -) # TAR CF - * | (CD / Opt / MySQL; TAR XFP -)
I used the command shown above to copy my database files. Я використовував команду показано вище, щоб скопіювати мої файли бази даних. What it does is it compresses the entire contents of the current directory, changes to the location of the destination directory ( /opt/mysql in this case), and then extracts the archive. Що вона робить, це він стискає весь вміст поточного каталогу, зміни до місця призначення каталозі (/ Opt / MySQL в даному випадку), а потім витягує архів.























2 Responses 2 Відповіді
Stay in touch with the conversation, subscribe to the Залишайтеся на зв'язку при розмові, підпишіться на RSS feed for comments on this post RSS-канал для коментарів на цю посаду . .
Continuing the Discussion Продовжуючи розмову