The other day I needed to migrate a directory containing a lot of files from one location on my Linux server to another. Onehdy som potreboval preniesť adresáre, ktoré obsahujú veľké množstvo súborov z jedného miesta na svojom serveri Linuxu na iný. There are a number of ways I could do this. Existuje niekoľko spôsobov, ako by som mohol urobiť. Using a simple cp command could have done the trick. Pomocou jednoduchého príkazu cp mohli urobiť trik. 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. Avšak, ako som bol kopírovanie dát bola databáza a chcel som, aby sa ubezpečil, že kopírovanie prebehlo perfektne, som sa pozrel na internet a našiel skvelý jeden riadok bash riešenia.
I wanted to move the contents of the directory /var/lib/mysql to /opt/mysql . Chcel som presunúť obsah adresára / var / lib / mysql do / opt / mysql. First I changed to the directory /var/lib/mysql : Najprv som zmenil do adresára / var / lib / mysql:
# cd /var/lib/mysql # Cd / var / lib / mysql
Then I ran the following one liner to do the magic for me. Potom som bežal za jedno lodných urobiť kúzlo pre mňa.
# 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. Použil som príkaz uvedené vyššie, kopii moje súbory databáz. 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. Čo to urobí, je to komprimuje celý obsah aktuálneho adresára, zmeny umiestnenie cieľového adresára (/ opt / mysql v tomto prípade), a potom extrahuje archív.























2 Responses 2 Citlivosť
Stay in touch with the conversation, subscribe to the Zostať v kontakte s konverzácia, prihláste sa RSS feed for comments on this post RSS kanál pre komentáre k tomuto príspevku . .
Continuing the Discussion Pokračovanie Diskusia