sync-dd 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #! /bin/bash
  2. # Copyright (C) 2011,2013, Joerg Jaspert <joerg@debian.org>
  3. # Copyright (C) 2012, Ansgar Burchardt <ansgar@debian.org>
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License as
  7. # published by the Free Software Foundation; version 2.
  8. #
  9. # This program is distributed in the hope that it will be useful, but
  10. # WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. set -e
  18. set -u
  19. set -E
  20. export LANG=C
  21. export LC_ALL=C
  22. export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars
  23. . $SCRIPTVARS
  24. usage() {
  25. echo "usage: $0 <lock> <host1> <host2> sync|code"
  26. echo
  27. echo "sync dd-accessible copy of the archive"
  28. echo
  29. echo "arguments:"
  30. echo " lock: file used for locking"
  31. echo " host1: hostname for syncing /srv/ftp-master.debian.org"
  32. echo " host2: hostname for syncing /srv/ftp.debian.org"
  33. echo " sync|code: sync syncs everything"
  34. echo " code only syncs the dak/ directory (uses host1 value as target)"
  35. exit ${1:-0}
  36. }
  37. if [ $# -ne 4 ]; then
  38. usage 1
  39. fi
  40. lockfile="${lockdir}/${1}"
  41. host1="${2}"
  42. host2="${3}"
  43. mode="${4}"
  44. # extra options for rsync of /srv/ftp-master.debian.org
  45. extra1=""
  46. cleanup() {
  47. rm -f "${lockfile}"
  48. }
  49. trap cleanup EXIT TERM HUP INT QUIT
  50. # Also, NEVER use --delete-excluded!
  51. if lockfile -r3 "${lockfile}" 2> /dev/null; then
  52. case "${mode}" in
  53. sync)
  54. rsync -aH -B8192 \
  55. ${extra1} \
  56. --exclude "/.nobackup" \
  57. --exclude "/archive/" \
  58. --exclude "/backup/*.xz" \
  59. --exclude "/backup/dump*" \
  60. --exclude "/build-queues/" \
  61. --exclude "/database/*.db" \
  62. --exclude ".da-backup.trace" \
  63. --exclude "/export/changelogs/tmp*/" \
  64. --exclude "/ftp" \
  65. --exclude "lost+found" \
  66. --exclude "/lock/" \
  67. --exclude "/mirror" \
  68. --exclude "/morgue/" \
  69. --exclude "/queue/bts_version_track/" \
  70. --exclude "/queue/unchecked/" \
  71. --exclude "/s3kr1t" \
  72. --exclude "/scripts/s3kr1t" \
  73. --exclude "/tmp/" \
  74. --exclude "/public/incoming.debian.org" \
  75. --exclude "/tiffani/" \
  76. --delete --delete-after \
  77. --timeout 3600 \
  78. -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
  79. /srv/ftp-master.debian.org/ "${host1}:/srv/ftp-master.debian.org/"
  80. # command for the remote side:
  81. # command="rsync --server -lHogDtpre.iLsf -B8192 --timeout=3600 --delete-after . /srv/ftp-master.debian.org/"
  82. rsync -aH -B8192 \
  83. --exclude "/.nobackup" \
  84. --exclude mirror \
  85. --exclude rsync/ \
  86. --exclude lost+found \
  87. --exclude .da-backup.trace \
  88. --exclude web-users/ \
  89. --delete --delete-after \
  90. --timeout 3600 \
  91. -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
  92. /srv/ftp.debian.org/ "${host2}:/srv/ftp.debian.org/"
  93. # command for the remote side:
  94. # command="rsync --server -lHogDtpre.iLsf -B8192 --timeout=3600 --delete-after . /srv/ftp.debian.org/"
  95. ;;
  96. code)
  97. rsync -aH -B8192 \
  98. --exclude "/.nobackup" \
  99. --delete --delete-after \
  100. --timeout 3600 \
  101. -e 'ssh -o ConnectTimeout=30 -o SetupTimeout=30' \
  102. /srv/ftp-master.debian.org/dak/ "${host1}:/srv/ftp-master.debian.org/dak/"
  103. # command for the remote side:
  104. # command="rsync --server -lHogDtpre.iLsf -B8192 --timeout=3600 --delete-after . /srv/ftp-master.debian.org/dak/"
  105. ;;
  106. *)
  107. echo "Unknown mode ${mode}." >&2
  108. exit 1
  109. ;;
  110. esac
  111. else
  112. #echo "Couldn't get the lock, not syncing"
  113. exit 0
  114. fi