{"id":67,"date":"2009-12-09T09:00:00","date_gmt":"2009-12-08T23:00:00","guid":{"rendered":"https:\/\/www.serenux.com\/?p=67"},"modified":"2021-01-14T09:14:42","modified_gmt":"2021-01-13T23:14:42","slug":"howto-migrate-an-apt-mirror-generated-ubuntu-archive-to-another-mirror-source-or-merge-a-foreign-apt-mirror-archive-into-yours","status":"publish","type":"post","link":"https:\/\/www.serenux.com\/index.php\/2009\/12\/09\/howto-migrate-an-apt-mirror-generated-ubuntu-archive-to-another-mirror-source-or-merge-a-foreign-apt-mirror-archive-into-yours\/","title":{"rendered":"HowTo: Migrate an Apt-Mirror-generated Ubuntu archive to another mirror source or merge a foreign Apt-Mirror archive into yours"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">So, you\u2019ve gone and&nbsp;<a href=\"https:\/\/web.archive.org\/web\/20150315210853\/http:\/\/www.serenux.com\/2008\/10\/howto-setup-your-own-local-ubuntu-repository-mirror\/\" target=\"_blank\" rel=\"noreferrer noopener\">created your very own local Ubuntu mirror using Apt-Mirror<\/a>, and you\u2019ve come across a situation similar to:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>You\u2019ve decided to change where you update your Apt-Mirror archive from (eg: you\u2019ve changed ISP\u2019s or feel that another source is more reliable than your current one to update from)<\/li><li>You\u2019re adding another large repository to your Apt-Mirror archive (such as the next version of Ubuntu) and don\u2019t have the quota to download it, so you\u2019re getting a friend to download it for you from their free server using Apt-Mirror (eg: iiNet and Internode customers can access their respective Ubuntu mirrors for free), so you need to be able to merge it with your own Apt-Mirror archive and have it update from your preferred source afterwards.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So how do you do this? Read on.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em><strong>Migrating your Apt-Mirror archive to update from a new source<\/strong><\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This one is really easy. Let\u2019s say you are updating your Ubuntu mirror from Internode, but now want to get your updates from iiNet. To make this happen you need to change the following files:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Your&nbsp;<em>\/etc\/apt\/mirror.list<\/em>&nbsp;file needs to be updated to point to the new source, and<\/li><li>the Apt-Mirror\u2019s record of downloaded files needs to be updated so that it doesn\u2019t waste time trying to re-download the entire mirror again not realising that it\u2019s already got 99% of all the files already, because Apt-Mirror tracks the files it has downloaded by the source URL and filename, not just the filenames themselves.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So let\u2019s go through this.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Open a terminal load your\u00a0<em>\/etc\/apt\/mirror.list<\/em>\u00a0file into your favourite text editor. In this case I will use the Nano text editor:<br><br><code>$ sudo nano \/etc\/apt\/mirror.list<\/code><br><\/li><li>In your\u00a0<em>mirror.list<\/em>\u00a0file, The lines for updating Ubuntu 32 and 64-bit versions plus source code from Internode can look similar to this:<br><br><code># Ubuntu 9.10 Karmic Koala 32-bit<\/code><br><code>deb-i386<\/code> <code>http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic main restricted universe multiverse<\/code><br><code>deb-i386 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-updates main restricted universe multiverse<\/code><br><code>deb-i386 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-backports main restricted universe multiverse<\/code><br><code>deb-i386 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-security main restricted universe multiverse<\/code><br><code>deb-i386 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-proposed main restricted universe multiverse<\/code><br><br><code># Ubuntu 9.10 Karmic Koala 64-bit<\/code><br><code>deb-amd64 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic main restricted universe multiverse<\/code><br><code>deb-amd64 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-updates main restricted universe multiverse<\/code><br><code>deb-amd64 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-backports main restricted universe multiverse<\/code><br><code>deb-amd64 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-security main restricted universe multiverse<\/code><br><code>deb-amd64 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-proposed main restricted universe multiverse<\/code><br><br><code># Ubuntu 9.10 Karmic Koala Source<\/code><br><code>deb-src http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic main restricted universe multiverse<\/code><br><code>deb-src http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-updates main restricted universe multiverse<\/code><br><code>deb-src http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-backports main restricted universe multiverse<\/code><br><code>deb-src http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-security main restricted universe multiverse<\/code><br><code>deb-src http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-proposed main restricted universe multiverse<\/code><br><\/li><li>We need to change the Internode URL to the iiNet URL, so bring up Nano\u2019s search and replace function by pressing CTRL+Backslash (\u201c\\\u201d<img decoding=\"async\" src=\"https:\/\/web.archive.org\/web\/20150315210853im_\/http:\/\/www.serenux.com\/wp-content\/themes\/grey-opaque\/plugins\/lazy-load\/images\/1x1.trans.gif\" alt=\"Smilie: ;)\">).<br><\/li><li>Now type in the text to replace, in this case:<br><br><code>http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu<\/code><br><\/li><li>Press Enter and you\u2019ll be prompted for the text to replace this with. In this case it\u2019s:<br><br><code>http:\/\/ftp.iinet.net.au\/pub\/ubuntu\/<\/code><br><\/li><li>Press Enter and Nano will find the first occurrence of the Internode text string and highlight it for you. If the selection is correct, press \u201cA\u201d on the keyboard to automatically replace \u201call\u201d occurrences.<br><\/li><li>Once the update is done, manually go back and visually verify that all the entries were changed correctly.<br><\/li><li>When you\u2019re happy, save your changes by pressing CTRL+X, then \u201cY\u201d and then Enter.<br><\/li><li>Now we need to update the Apt-Mirror record of downloaded files. First, let\u2019s take a backup of the index in case you stuff up. Type in:<br><br><code>$ sudo cp \/var\/spool\/apt-mirror\/var\/ALL \/var\/spool\/apt-mirror\/var\/ALL_Backup<\/code><br><br><em>NOTE: the filename \u201cALL\u201d must be in uppercase<\/em><br><\/li><li>Now let\u2019s bring up the original file into the Nano text editor.<br><br><code>$ sudo nano \/var\/spool\/apt-mirror\/var\/ALL<\/code><br><\/li><li>Depending how large your index file is, there may be a brief delay while Nano opens it up. Once it appears, do the same search and replace as you did in steps 3-6 again.\u00a0<em>Note: If the editor comes up blank, then you have not opened up the index file \u2013 check your path spelling in Step 9 and try again.<\/em><br><\/li><li>Save your changes by pressing CTRL+X, then \u201cY\u201d and then Enter.<br><\/li><li>Finally, we need to modify the Apt-Mirror\u2019s cache of downloaded files so that its directory structure matches that of the new source. In the case of iiNet, you\u2019ll notice it\u2019s URL has one less\u00a0<em>ubuntu<\/em>\u00a0word in it compared to Internode\u2019s URL, so we\u2019ll need to move some directories to eliminate the extra\u00a0<em>ubuntu<\/em>\u00a0directory.<br><br>At the terminal, move the\u00a0<em>dists<\/em>\u00a0and\u00a0<em>pool<\/em>\u00a0directories of the mirrored files one directory back using the commands:<br><br><code>$ sudo mv \/var\/spool\/apt-mirror\/mirror\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu\/dists \/var\/spool\/apt-mirror\/mirror\/mirror.internode.on.net\/pub\/ubuntu<br>$ sudo mv \/var\/spool\/apt-mirror\/mirror\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu\/pool \/var\/spool\/apt-mirror\/mirror\/mirror.internode.on.net\/pub\/ubuntu<\/code><br><\/li><li>Now rename the\u00a0<em>mirror.internode.on.net<\/em>\u00a0directory to become the name of the iiNet server:<br><br><code>$ sudo mv \/var\/spool\/apt-mirror\/mirror\/mirror.internode.on.net \/var\/spool\/apt-mirror\/mirror\/ftp.iinet.net.au<\/code><br><\/li><li>The directory structure now matches iiNet\u2019s server and your\u00a0<em>ALL<\/em>\u00a0file is up to date, so now we can test your changes by launching Apt-Mirror. Launch it manually with:<br><br><code>$ apt-mirror<\/code><br><\/li><li>Watch the output. First Apt-Mirror will download all the repository indexes from the new location and will compare the files presented in those indexes to your local index of downloaded files (the modified\u00a0<em>ALL<\/em>\u00a0file). It will skip all files already listed as being present and will only download new files not listed in your local mirror. You should find Apt-Mirror advises only a small subset of data to download, perhaps only a few megabytes or no more than a gigabyte or two since your last update under the old setup. If you see that Apt-Mirror wants to download some 30GB or more, then you have made an error in changing the URL in the ALL index file or you incorrectly renamed the mirror directories. Press CTRL+C to stop Apt-Mirror, and go check your configuration from Step 10.<br><br><code>$ apt-mirror<br>Downloading 1080 index files using 5 threads...<br>Begin time: Wed Dec\u00a0 9 15:59:23 2009<br>[5]... [4]... [3]... [2]... [1]... [0]...<br>End time: Wed Dec\u00a0 9 16:00:45 2009<br><br>Proceed indexes: [SSSSSSSSSSPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP]<br><br>1.7 GiB will be downloaded into archive.<br>Downloading 998 archive files using 5 threads...<br>Begin time: Wed Dec\u00a0 9 16:02:31 2009<br>[5]... [4]... [3]... [2]... [1]... [0]...<br>End time: Wed Dec\u00a0 9 16:54:15 2009<br><br>207.4 MiB in 256 files and 1 directories can be freed.<br>Run \/var\/spool\/apt-mirror\/var\/clean.sh for this purpose.<br>$<\/code><br><\/li><li>You\u2019re done! Pat yourself on the back.\u00a0<img decoding=\"async\" src=\"https:\/\/web.archive.org\/web\/20150315210853im_\/http:\/\/www.serenux.com\/wp-content\/themes\/grey-opaque\/images\/smilies\/icon_smile.gif\" alt=\"Smilie: :)\"><\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><em><strong>Inserting a foreign Apt-Mirror archive into your own archive<\/strong><\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This one is slightly more involved, but is not difficult. In the case of a full Ubuntu Mirror, let\u2019s say you were adding an Ubuntu Karmic mirror archive taken from iiNet\u2019s mirror servers into your own local Apt-Mirror archive that featured only Intrepid and Jaunty, both of which you are updating from Internode\u2019s mirror servers. There are some obstacles we need to overcome such as:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Continuing to perform future updates for the Karmic repository from Internode rather than iiNet.<\/li><li>The foreign iiNet Karmic archive contains lots of files that you already have in your own archive \u2013 files that are common between all releases of Ubuntu. How do you filter those ones out and only copy the new files?<\/li><li>Finally, how do you update the Apt-Mirror index file with the potentially thousands of new entries from the foreign archive? How do you avoid duplicate lines potentially confusing Apt-Mirror?<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>First ensure that you have the full copy of the foreign Apt-Mirror archive supplied on a suitable storage medium. Aside from the mirror directory itself (usually under\u00a0<em>\/var\/spool\/apt-mirror\/mirror<\/em>), you must have a copy of its\u00a0<em>\/var\/spool\/apt-mirror\/var\/ALL<\/em>\u00a0file. It does not matter if the foreign mirror is not completely up to date, as Apt-Mirror will catch up with what is missing when you run the next update.<br><\/li><li>Let\u2019s prepare your local Apt-Mirror installation for grabbing Ubuntu Karmic from our preferred source first. We need to load up the\u00a0<em>\/etc\/apt\/mirror.list<\/em>\u00a0file into your favourite text editor and add the entries relevant to our new repository that we are mirroring. I will use the Nano text editor for this, but you can use any text editor you like:<br><br><code>$ sudo nano \/etc\/apt\/mirror.list<\/code><br><\/li><li>Now we add the entries relevant to Ubuntu Karmic for Apt-Mirror to use. In this case, I am going to update Ubuntu Karmic from Internode and I will be grabbing both the 32-bit and 64-bit versions plus the source code (reflecting what is already included in the foreign archive on my storage medium, or Apt-Mirror will be doing a LOT of downloading the next time you run it), so I need to add the following entries:<br><br><code># Ubuntu 9.10 Karmic Koala 32-bit<br>deb-i386 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic main restricted universe multiverse<br>deb-i386 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-updates main restricted universe multiverse<br>deb-i386 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-backports main restricted universe multiverse<br>deb-i386 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-security main restricted universe multiverse<br>deb-i386 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-proposed main restricted universe multiverse<br><br># Ubuntu 9.10 Karmic Koala 64-bit<br>deb-amd64 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic main restricted universe multiverse<br>deb-amd64 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-updates main restricted universe multiverse<br>deb-amd64 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-backports main restricted universe multiverse<br>deb-amd64 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-security main restricted universe multiverse<br>deb-amd64 http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-proposed main restricted universe multiverse<br><br># Ubuntu 9.10 Karmic Koala Source<br>deb-src http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic main restricted universe multiverse<br>deb-src http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-updates main restricted universe multiverse<br>deb-src http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-backports main restricted universe multiverse<br>deb-src http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-security main restricted universe multiverse<br>deb-src http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu karmic-proposed main restricted universe multiverse<\/code><br><\/li><li>Save your changes and exit the editor using CTRL+X, then \u201cY\u201d and then Enter.<br><\/li><li>Make a backup copy of the foreign mirror\u2019s\u00a0<em>\/var\/spool\/apt-mirror\/var\/ALL<\/em>\u00a0file, so you can revert to it if you make a mistake. Call the copy something like\u00a0<em>ALL_Backup<\/em>.<br><\/li><li>Now open the foreign mirror\u2019s original\u00a0<em>\/var\/spool\/apt-mirror\/var\/ALL<\/em>\u00a0file into your favourite text editor.<br><\/li><li>Use your text editor\u2019s search and replace function (in Nano, press CTRL + Backslash \u201c\\\u201d)\u00a0to replace the URL of each entry in the foreign mirror\u2019s\u00a0<em>ALL<\/em>\u00a0file to the URL of the mirror you will be performing your future updates from. In the case of changing iiNet URLs to Internode URLs, you would replace any occurrence of the text string:<br><br><code>http:\/\/ftp.iinet.net.au\/pub\/ubuntu<\/code><br>\u2026with\u2026<br><code>http:\/\/mirror.internode.on.net\/pub\/ubuntu\/ubuntu<\/code><br><\/li><li>Once updated, save your changes and close your text editor.<br><\/li><li>Now we need to merge the modified foreign\u00a0<em>ALL<\/em>\u00a0file into the\u00a0<em>ALL<\/em>\u00a0file from your local Apt-Mirror setup. First up, rename the modified foreign\u00a0<em>ALL<\/em>\u00a0file so we don\u2019t confuse it. For this tutorial, I will assume your foreign mirror is supplied on an external USB hard-drive called \u201cmyhdd\u201d and is simply a copy of the foreign system\u2019s\u00a0<em>\/var<\/em>\u00a0directory in its entirety. The following will rename the file from\u00a0<em>ALL<\/em>\u00a0to\u00a0<em>ALL_modified<\/em>\u00a0in a terminal:<br><br><code>$ mv \/media\/myhdd\/var\/spool\/apt-mirror\/var\/ALL \/media\/myhdd\/var\/spool\/apt-mirror\/var\/ALL_modified<\/code><br><\/li><li>Now concatenate the original\u00a0<em>ALL<\/em>\u00a0file and the modified foreign mirror\u2019s\u00a0<em>ALL_modified<\/em>\u00a0file into one new file called\u00a0<em>ALL_new<\/em>\u00a0in your local Apt-Mirror\u2019s\u00a0<em>var<\/em>\u00a0directory. Concatenating alone\u00a0will\u00a0result in duplicate lines and we need to sort the file so that any duplicate lines in both the local and foreign\u00a0<em>ALL<\/em>\u00a0files are brought together. We can sort the content of the concatenated files and remove duplicate lines in one hit with:$ sudo cat \/var\/spool\/apt-mirror\/var\/ALL \/media\/myhdd\/var\/spool\/apt-mirror\/var\/ALL_modified | sort | uniq > \/var\/spool\/apt-mirror\/var\/ALL_new The\u00a0<em>cat<\/em>\u00a0part of the command simply joins the content of\u00a0<em>\/var\/spool\/apt-mirror\/var\/ALL<\/em>\u00a0and\u00a0<em>\/media\/myhdd\/var\/spool\/apt-mirror\/var\/ALL_modified<\/em>\u00a0into one big file, but before it\u2019s written to a physical file, the concatenated data is \u201cpiped\u201d using the pipe symbol \u201c|\u201d into the\u00a0<em>sort<\/em>\u00a0command, which sorts the concatenated data into alphabetical order which will group duplicate lines together. But before that resultant output is written anywhere, the sorted data is then piped again into the\u00a0<em>uniq<\/em>\u00a0command which automagically removes all duplicate lines, leaving one unique copy of each line. Finally, we direct the output from\u00a0<em>uniq<\/em>\u00a0using the \u201c>\u201d character into our physical destination file at\u00a0<em>\/var\/spool\/apt-mirror\/var\/ALL_new<\/em>\u00a0at the end. The\u00a0<em>sudo<\/em>\u00a0command at the start is used simply because only the\u00a0<em>root<\/em>\u00a0and the\u00a0<em>apt-mirror<\/em>\u00a0users can actually write to the\u00a0<em>\/var\/spool\/apt-mirror\/var<\/em>\u00a0directory.<br><br>Alternatively, we can replace the \u201c<em>| sort | uniq<\/em>\u201d part with \u201c<em>| sort -u<\/em>\u201d which does the exact same thing, since the sort command does have it\u2019s own \u201cunique\u201d functionality as well. I\u2019ll leave it up to you which way you\u2019d like to go.<br><\/li><li>Check your new\u00a0<em>\/var\/spool\/apt-mirror\/var\/ALL_new<\/em>\u00a0file and you will find it now contains all your local and foreign mirror\u2019s entries in alphabetical order and with no duplicate lines. If you\u2019d like to see how this worked, re-work Step 10 without the\u00a0<em>sort<\/em>\u00a0and\u00a0<em>uniq<\/em>\u00a0commands or the pipe characters and see how it affects the output file. Try adding just the\u00a0<em>sort<\/em>\u00a0or just the\u00a0<em>uniq<\/em>\u00a0command too.<br><\/li><li>Now rename your local mirror\u2019s original\u00a0<em>ALL<\/em>\u00a0file because we\u2019re about to replace it with the new one:<br><br><code>$ sudo mv \/var\/spool\/apt-mirror\/var\/ALL \/var\/spool\/apt-mirror\/var\/ALL_old<\/code><br><\/li><li>Now rename the new\u00a0<em>ALL<\/em>_new file to take the place of the old one:<br><br><code>$ sudo mv \/var\/spool\/apt-mirror\/var\/ALL_new \/var\/spool\/apt-mirror\/var\/ALL<\/code><br><\/li><li>Right, that\u2019s the index taken care of. We\u2019re nearly done! Now we only have to merge the foreign mirror\u2019s actual files into your local mirror. Once again, for the purposes of this tutorial I\u2019m going to assume you have them stored on an external USB hard-drive called \u201cmyhdd\u201d and is a copy of the foreign system\u2019s entire\u00a0<em>\/var<\/em>\u00a0directory, so the path to the foreign mirror\u2019s files will be\u00a0<em>\/media\/myhdd\/var\/spool\/apt-mirror\/mirror<\/em>\u00a0\u2013 got that? Let\u2019s change to that directory now in a terminal to save us having to type so much:<br><br><code>$ cd \/media\/myhdd\/var\/spool\/apt-mirror\/mirror<\/code><br><\/li><li>Now, the observant of you may have noticed that Apt-Mirror stores its mirrored files using a directory structure that follows the path of the URL the data is obtained from, so in the case of a mirror from iiNet, there is a directory here called\u00a0<em>ftp.iinet.net.au<\/em>. You can see it by using the\u00a0<em>ls<\/em>\u00a0command to list the directory contents:<br><br><code>$ ls -l<br>-rw-r--r--\u00a0 1 apt-mirror apt-mirror\u00a0\u00a0 198599 2009-12-09 10:19 access.log<br>-rw-r--r--\u00a0 1 apt-mirror apt-mirror\u00a0\u00a0 544373 2009-12-01 06:45 access.log.1<br>-rw-r--r--\u00a0 1 apt-mirror apt-mirror\u00a0 1863467 2009-11-03 06:44 access.log.2<br>-rw-r--r--\u00a0 1 apt-mirror apt-mirror\u00a0 1865334 2009-10-01 06:28 access.log.3<br>-rw-r--r--\u00a0 1 apt-mirror apt-mirror 18152891 2009-09-01 06:42 access.log.4<br>-rw-r--r--\u00a0 1 apt-mirror apt-mirror\u00a0\u00a0\u00a0\u00a0 6135 2009-12-09 06:46 error.log<br>-rw-r--r--\u00a0 1 apt-mirror apt-mirror\u00a0\u00a0\u00a0 33898 2009-12-01 06:45 error.log.1<br>-rw-r--r--\u00a0 1 apt-mirror apt-mirror\u00a0\u00a0 124512 2009-11-03 06:44 error.log.2<br>-rw-r--r--\u00a0 1 apt-mirror apt-mirror\u00a0\u00a0 554851 2009-10-01 06:28 error.log.3<br>-rw-r--r--\u00a0 1 apt-mirror apt-mirror\u00a0\u00a0 831227 2009-09-01 06:42 error.log.4<br><strong>drwxr-xr-x\u00a0 3 apt-mirror apt-mirror\u00a0\u00a0\u00a0\u00a0 4096 2008-09-11 02:00 ftp.iinet.net.au<\/strong><br><\/code>$<br><\/li><li>We need to modify the foreign directory names and structure to exactly match that of the URL path your local mirror updates from. Starting with the obvious, we need to rename the\u00a0<em>ftp.iinet.net.au<\/em>\u00a0directory to be\u00a0<em>mirror.internode.on.net<\/em>\u00a0with:<br><br><code>$ sudo mv ftp.iinet.net.au mirror.internode.on.net<\/code><br><\/li><li>Next we need to create an extra subdirectory called \u201cubuntu\u201d because Internode\u2019s URL path is\u00a0<em>mirror.internode.on.net\/pub\/ubuntu\/<strong>ubuntu\/<\/strong><\/em>\u00a0and iiNet\u2019s path is\u00a0<em>ftp.iinet.net.au\/pub\/ubuntu\/<\/em>\u00a0only:<br><br><code>$ sudo mkdir mirror.internode.on.net\/pub\/ubuntu\/ubuntu<\/code><br><\/li><li>Now we need to move the \u201cdists\u201d and \u201cpool\u201d directories under the first \u201cubuntu\u201d directory to be under the second \u201cubuntu\u201d directory:<br><br><code>$ sudo mv mirror.internode.on.net\/pub\/ubuntu\/dists mirror.internode.on.net\/pub\/ubuntu\/ubuntu<br>$ sudo mv mirror.internode.on.net\/pub\/ubuntu\/pool mirror.internode.on.net\/pub\/ubuntu\/ubuntu<\/code><br><\/li><li>With the directory structure and directory names all amended, we are now ready to merge the foreign mirror\u2019s files into your local mirror. We will do this using RSync. This tool traditionally is used to make backups and is indeed used to keep the official worldwide Ubuntu mirrors up to date 1:1 with the master archive, but in our case we are using it to add the \u201cmissing\u201d files in the local mirror with the files from the foreign mirror whilst skipping the files that are already present, which means instead of copying around about 60GB worth of data from the foreign mirror, we\u2019ll only copy a percentage of that instead, saving us time and drive space:<br><br><code>$ sudo rsync -avz --progress \/media\/myhdd\/var\/spool\/apt-mirror\/mirror\/mirror.internode.on.net \/var\/spool\/apt-mirror\/mirror\/<\/code><br><\/li><li>The \u201c\u2013progress\u201d parameter allows you to see which file is being copied over. You may see a large number of directory names whizz past because those directories don\u2019t have any files that are different between your current Ubuntu Intrepid and Jaunty mirror and the Karmic mirror you are merging. Unfortunately rsync does not provide an all-over progress. It only provides a progress of the file it is currently working on. This procress can take several hours to complete depending on how much data needs to be copied and the speed of your storage medium containing the foreign mirror (which if on a USB HDD can take a looooong time).<br><\/li><li>Once RSync has finished, it will give a summary of what was copied. If you were to run the rsync command in Step 16 again, you will see it finish rather quickly because there is no data that has changed or is missing anymore.<br><\/li><li>Now we just quickly ensure that all the merged foreign files belong to the Apt-Mirror user with:<br><br><code>$ sudo chown apt-mirror:apt-mirror -R \/var\/spool\/apt-mirror<\/code><br><\/li><li>And now we are ready to try a manual update to see if it all worked. If you now execute the Apt-Mirror application manually, you should now see that it reads in the new repository entries you added into your \/etc\/apt\/mirror.list file in Step 3 and will compare the files presented in those indexes to your local index of downloaded files (the newly modified\u00a0<em>ALL<\/em>\u00a0file). It will skip all files already present and will only download new files not present in your local mirror. You should find Apt-Mirror advises only a small subset of data to download, perhaps only a few megabytes or a gigabyte or two since your last update under the old setup and depending on how old the foreign archive was. If you see that Apt-Mirror wants to download about 30GB or more, then you have made an error in changing the URL in the\u00a0<em>ALL<\/em>\u00a0index file or the renaming of mirror directories. Press CTRL+C to stop Apt-Mirror, and go check your configuration from Step 5.<br><br><code>$ apt-mirror<br>Downloading 1080 index files using 5 threads...<br>Begin time: Wed Dec\u00a0 9 15:59:23 2009<br>[5]... [4]... [3]... [2]... [1]... [0]...<br>End time: Wed Dec\u00a0 9 16:00:45 2009<br><br>Proceed indexes: [SSSSSSSSSSPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP]<br><br>1.7 GiB will be downloaded into archive.<br>Downloading 998 archive files using 5 threads...<br>Begin time: Wed Dec\u00a0 9 16:02:31 2009<br>[5]... [4]... [3]... [2]... [1]... [0]...<br>End time: Wed Dec\u00a0 9 16:54:15 2009<br><br>207.4 MiB in 256 files and 1 directories can be freed.<br>Run \/var\/spool\/apt-mirror\/var\/clean.sh for this purpose.<br>$<\/code><br><\/li><li>If all is good, then pat yourself on the back. You\u2019ve successfully merged the foreign repository and it will now update from your preferred ISP\u2019s mirror from now on.\u00a0<img decoding=\"async\" src=\"https:\/\/web.archive.org\/web\/20150315210853im_\/http:\/\/www.serenux.com\/wp-content\/themes\/grey-opaque\/images\/smilies\/icon_smile.gif\" alt=\"Smilie: :)\"><\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>So, you\u2019ve gone and&nbsp;created your very own local Ubuntu mirror using Apt-Mirror, and you\u2019ve come across a situation similar to: You\u2019ve decided to change where you update your Apt-Mirror archive from (eg: you\u2019ve changed ISP\u2019s or feel that another source is more reliable than your current one to update from) You\u2019re adding another large repository [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":1,"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":68,"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions\/68"}],"wp:attachment":[{"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}