First there's a subtle but important difference between using the
-t switch and the
apt-get install <package>/squeeze-backports - This will install from squeeze-backports and dependencies from stable
apt-get -t squeeze-backports install <package> - This will install both and dependencies from squeeze-backports.
Just as a first pass try giving the
$package/$suite switch as apt-get will then try to install postgresql and postgresql-common from squeeze-backports but not its dependencies (in this case logrotate).
I don't have a Squeeze system to test with, but I think this is what is happening:
Squeeze is no longer the current release of Stable and is now oldstable. Squeeze-backports pulls its packages from the then version of testing (Wheezy) which is now the current Stable. The version of postgresql that you are trying to install is actually from the current version of Stable but was designed to run with most of its dependencies from oldstable (i.e., logrotate 3.7.8-6 from oldstable/squeeze compared to logrotate 3.8.1-4 from stable/wheezy) but since squeeze-backports and wheezy are roughly analogous using the
-t switch means that it's trying to pull logrotate from wheezy's repositories for some reason instead of being satisfied with version 3.7.8-6 which is included in oldstable/squeeze. Generally this is caused by either having the wheezy repositories added explicitly with bad apt-pinning policies setup or you have repositories that are pointed at a release-type (stable/testing/unstable) and not a Release (squeeze/wheezy) in which case you have a much larger problem.
You should endeavor to fix your issue by upgrading to Wheezy as it is the current version of Stable. This is the best solution for a whole number of reasons. If you can't or are unwilling to do that, try using the
-t switch so you don't pull the dependencies for postgresql from backports or using apt-pinning to pull the required stuff from Wheezy.
I hesitate to update Debian to Wheezy as I can easily break something important on the server.
Unfortunately, you are going to have to upgrade to Wheezy sooner or later. The Debian Security team only provides security patches for oldstable for roughly a year and so you really should already be planning to upgrade to Wheezy at this point. Please don't take this the wrong way, but if you don't have the expertise to do an upgrade you should seek out and hire someone who does.
I think you have two approaches: You can either do an in place upgrade from Squeeze to Wheezy or you can build a new Wheezy-based server and migrate from one to the other. The in place upgrade is actually pretty simple to do provided you have a healthy system to start with. I've seen some boxes that have been upgraded through three or four different release cycles and they work just fine. Make sure you read the release notes carefully and that you test both the upgrade process and your application/s in your development environment prior to doing the upgrade on your production server (which is presumably the one we're talking about). However it sounds like we're not working with a healthy server so I suggest you take the migration path as you'll get a nice clean slate.
It goes without saying that regardless of the path you take to Wheezy, you should already have a verified backup and recovery procedures.
If there is an easier way to solve my problem
Yes. There is an easier way to solve your immediate problem but it doesn't solve the root cause and professionals solve the root cause.
Look at your apt-cache policy results. You're pulling postgresql and postgresql-common from the non-debian apt.postgresql.org repositories but it looks like you have the ones added for Ubuntu (precise-pgdg) instead of Debian Squeeze (squeeze-pgdg) which could have an entirely different set of dependencies. In the case of logrotate it is 3.7.8-6ubuntu5 instead of the 3.7.8-6 from oldstable/squeeze.
Logrotate is being pulled from the Debian Stable repositories which means from Wheezy which is presumably out of sync with the rest of your oldstable/squeeze system. Your postgresql packages from Ubuntu Precise are looking for 3.7.8-6ubuntu5 but the closest you have is 3.8.1-4 from stable/wheezy.
You need to 1) stop using Ubuntu repositories when you're using Debian and 2) figure out what release (Squeeze or Wheezy) you're actually running and change the
Stable to that. I suspect that will fix your problem.
That being said, your
/etc/apt/sources.list is not at all configured correctly and there is a distinct possibility your server is pretty messed up. You shouldn't have Ubuntu repositories if you're using Debian. Ubuntu is based on Debian but they are two separate beasts and there is an unfortunate amount of advice on the Internet recommending that if you need a certain version of a package or a package that exists in the Ubuntu PPAs but not in the Debian repos to just add the Ubuntu PPAs. This is wrong. Please don't do it or listen to people that recommend it.
You're also tracking a release-type (stable) and not a Release (Squeeze or Wheezy). This means that as soon as Wheezy was released as Stable all of those packages became available. You may already be running Wheezy or some horrible amalgamation of Squeeze and Wheezy. This is also bad.
I really recommend you do a clean install and migrate your application there.
it was modified multiple times by different people
RCS is trivially simple to setup and use. I heartily recommend it for even the smallest of installations. It will help mitigate these problems in the future.