1、安装Debmirror同步软件

    1. yum install debmirror -y

    2、配置debmirror.conf

    1. [root@vm_10_*_*_124_centos ~]# cat /etc/debmirror.conf
    2. # Default config for debmirror
    3. # The config file is a perl script so take care to follow perl syntax.
    4. # Any setting in /etc/debmirror.conf overrides these defaults and
    5. # ~/.debmirror.conf overrides those again. Take only what you need.
    6. #
    7. # The syntax is the same as on the command line and variable names
    8. # loosely match option names. If you don't recognize something here
    9. # then just stick to the command line.
    10. #
    11. # Options specified on the command line override settings in the config
    12. # files.
    13. # Location of the local mirror (use with care)
    14. # $mirrordir="/path/to/mirrordir"
    15. # Output options
    16. $verbose=0;
    17. $progress=0;
    18. $debug=0;
    19. # Download options
    20. $host="mirrors.tuna.tsinghua.edu.cn";
    21. $user="anonymous";
    22. $passwd="anonymous@";
    23. $remoteroot="ubuntu";
    24. $download_method="sync";
    25. #@dists="bionic,bionic-updates,bionic-security";
    26. #@sections="main,restricted,universe,multiverse";
    27. #@arches="amd64";
    28. # @ignores="";
    29. # @excludes="";
    30. # @includes="";
    31. # @excludes_deb_section="";
    32. # @limit_priority="";
    33. $omit_suite_symlinks=0;
    34. $skippackages=0;
    35. # @rsync_extra="doc,tools";
    36. $i18n=0;
    37. $getcontents=0;
    38. $do_source=1;
    39. $max_batch=0;
    40. # @di_dists="dists";
    41. # @di_archs="arches";
    42. # Save mirror state between runs; value sets validity of cache in days
    43. $state_cache_days=0;
    44. # Security/Sanity options
    45. $ignore_release_gpg=1;
    46. $ignore_release=1;
    47. $check_md5sums=0;
    48. $ignore_small_errors=1;
    49. # Cleanup
    50. $cleanup=0;
    51. $post_cleanup=1;
    52. # Locking options
    53. $timeout=300;
    54. # Rsync options
    55. $rsync_batch=200;
    56. $rsync_options="-aIL --partial --bwlimit=800";
    57. # FTP/HTTP options
    58. $passive=0;
    59. # $proxy="http://proxy:port/";
    60. # Dry run
    61. $dry_run=0;
    62. # Don't keep diff files but use them
    63. $diff_mode="use";
    64. # The config file must return true or perl complains.
    65. # Always copy this.
    66. 1;

    3、调整同步脚本

    1. #### Start script to automate building of Ubuntu mirror #####
    2. ## THE NEXT LINE IS NEEDED THE REST OF THE LINES STARTING WITH A # CAN BE DELETED
    3. #!/bin/bash
    4. ## Setting variables with explanations.
    5. #
    6. # Don't touch the user's keyring, have our own instead
    7. #
    8. export GNUPGHOME=/root/.gnupg
    9. # Arch= -a # Architecture. For Ubuntu can be i386, powerpc or amd64.
    10. # sparc, only starts in dapper, it is only the later models of sparc.
    11. #
    12. arch=i386,amd64
    13. # Minimum Ubuntu system requires main, restricted
    14. # Section= -s # Section (One of the following - main/restricted/universe/multiverse).
    15. # You can add extra file with $Section/debian-installer. ex: main/debian-installer,universe/debian-installer,multiverse/debian-installer,restricted/debian-installer
    16. #
    17. section=main,restricted,universe,multiverse
    18. # Release= -d # Release of the system (...Hardy, Intrepid... Lucid, Precise, Quantal, Saucy, bionic ), and the -updates and -security ( -backports can be added if desired)
    19. # List of updated releases in: https://wiki.ubuntu.com/Releases
    20. #
    21. release=bionic,bionic-security,bionic-updates,bionic-backports,bionic-proposed
    22. # Server= -h # Server name, minus the protocol and the path at the end
    23. # CHANGE "*" to equal the mirror you want to create your mirror from. au. in Australia ca. in Canada.
    24. # This can be found in your own /etc/apt/sources.list file, assuming you have Ubuntu installed.
    25. #
    26. server=mirrors.tuna.tsinghua.edu.cn
    27. # Dir= -r # Path from the main server, so http://my.web.server/$dir, Server dependant
    28. #
    29. inPath=:ubuntu
    30. # Proto= --method= # Protocol to use for transfer (http, ftp, hftp, rsync)
    31. # Choose one - http is most usual the service, and the service must be available on the server you point at.
    32. #
    33. proto=rsync
    34. # Outpath= # Directory to store the mirror in
    35. # Make this a full path to where you want to mirror the material.
    36. #
    37. outPath=/yum_data/ubuntu
    38. # The --nosource option only downloads debs and not deb-src's
    39. # The --progress option shows files as they are downloaded
    40. # --source \ in the place of --no-source \ if you want sources also.
    41. # --nocleanup Do not clean up the local mirror after mirroring is complete. Use this option to keep older repository
    42. # Start script
    43. #
    44. if [ ! -e "/opt/ubuntu-sync/.ubuntu.sync" ];then
    45. touch /opt/ubuntu-sync/.ubuntu.sync;
    46. echo "">/opt/ubuntu-sync/sync.log;
    47. debmirror --no-check-gpg \
    48. --ignore-small-errors \
    49. --ignore-missing-release \
    50. --precleanup \
    51. -a $arch \
    52. --no-source \
    53. -s $section \
    54. -h $server \
    55. -d $release \
    56. -r $inPath \
    57. --progress \
    58. --method=$proto \
    59. --rsync-options "-aIL --partial --bwlimit=800" \
    60. $outPath >>/opt/ubuntu-sync/sync.log;
    61. rm "/opt/ubuntu-sync/.ubuntu.sync";
    62. else
    63. echo "ubuntu mirror is going on";
    64. fi
    65. #### End script to automate building of Ubuntu mirror ####

    4、添加计划任务

    1. [root@vm_10_*_*_124_centos ubuntu-sync]# crontab -l
    2. 0 */2 * * * /opt/ubuntu-sync/ubuntu-mirrorbuild.sh