The other day I needed to migrate a directory containing a lot of files from one location on my Linux server to another. Otro dienu man vajadzēja migrēt direktorija satur daudz failus no vienas vietas uz manu Linux servera uz citu. There are a number of ways I could do this. Ir veidos es varētu darīt šo numuru. Using a simple cp command could have done the trick. Izmantojot vienkāršu cp komanda varēja izdarīt triks. 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. Tomēr, kā dati biju kopēšana ir datubāzē, un es gribēju pārliecināties, ka kopēšanas tika izdarīts perfekti, paskatījos uz internetā un konstatēja izcili vienas līnijas bash risinājums tam.
I wanted to move the contents of the directory /var/lib/mysql to /opt/mysql . Es gribēju, lai pārvietotos no kataloga saturs / var / lib / mysql uz / opt / mysql. First I changed to the directory /var/lib/mysql : Vispirms es mainīta uz direktoriju / var / lib / mysql:
# cd /var/lib/mysql # Cd / var / lib / mysql
Then I ran the following one liner to do the magic for me. Tad es skrēja pēc viena līnijpārvadātāju darīt burvju par mani.
# tar cf – * | ( cd /opt/mysql; tar xfp -) # Tar cf - * | (cd / opt / mysql, darva XFP -)
I used the command shown above to copy my database files. Es lieto komandu kā iepriekš norādīts, nokopēt savu datubāzi failus. 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. Kas tas ir tas saspiež visu saturu no pašreizējā direktorijā, mainīt atrašanās vietu, mērķa direktoriju (/ opt / mysql šajā gadījumā), un tad ekstrakti arhīvā.























{ 3 trackbacks } (3 trackbacks)
{ 0 comments… (0 comments ... add one now pievienot vienu tagad } )
Leave a Comment Leave Comment